-
I have a Post resource and I want to show a preview of the content added with Tiptap. Nothing seems to work. This is the latest code: return $table
->columns(
[
Tables\Columns\TextColumn::make('published_at')->dateTime(),
Tables\Columns\TextColumn::make('title'),
Tables\Columns\TextColumn::make('content')->formatStateUsing(
fn ($state) => $state ? json_decode($state)->document->content[0]->content : ''
),
Tables\Columns\TextColumn::make('mood')->formatStateUsing(
fn ($state) => match ($state) {
1 => '😪',
2 => '🫤',
3 => '😐',
4 => '🙂',
5 => '😊',
}
),
]
) In particular, this code throws a Any help appreciated! |
Beta Was this translation helpful? Give feedback.
Answered by
awcodes
Feb 15, 2024
Replies: 1 comment 1 reply
-
I just do it as an attribute on the model public function excerpt(): Attribute
{
$data = $this->content ? tiptap_converter()->asText($this->content) : null;
return new Attribute(
get: fn (): ?string => Str::of(strip_tags($data ?? $this->seo->description))->limit(300),
);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
iign
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just do it as an attribute on the model