Skip to content

Is there a way to show a content or content excerpt in a listing table? #331

Answered by awcodes
iign asked this question in Q&A
Discussion options

You must be logged in to vote

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),
    );
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@iign
Comment options

Answer selected by iign
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants