From 52fa5fbc63c68187a6f4a92955c53803c1c326f9 Mon Sep 17 00:00:00 2001 From: Jeremy Layson Date: Mon, 8 Apr 2024 10:16:05 +0800 Subject: [PATCH] Fix HasExcerpt failing on some cases --- src/Filament/Traits/HasExcerpt.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Filament/Traits/HasExcerpt.php b/src/Filament/Traits/HasExcerpt.php index 188c52f6..d8001951 100644 --- a/src/Filament/Traits/HasExcerpt.php +++ b/src/Filament/Traits/HasExcerpt.php @@ -18,7 +18,15 @@ public function excerpt(): Attribute $paragraph = ''; foreach ($content as $key => $value) { if ($value['type'] === 'paragraph') { - $paragraph = $value['content'][0]['text']; // take the first part + if (isset($value['content'])) { + foreach ($value['content'] as $key => $valueContent) { + // find first instance of text + if (isset($valueContent['text'])) { + $paragraph = $valueContent['text']; // take the first part + break; + } + } + } } }