XetaIO /
Xetaravel
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Xetaravel\Models\Presenters; |
||
| 6 | |||
| 7 | use GrahamCampbell\Markdown\Facades\Markdown; |
||
| 8 | use Illuminate\Database\Eloquent\Casts\Attribute; |
||
| 9 | |||
| 10 | trait BlogCommentPresenter |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Get the content parsed in HTML. |
||
| 14 | * |
||
| 15 | * @return Attribute |
||
| 16 | * |
||
| 17 | */ |
||
| 18 | protected function contentMarkdown(): Attribute |
||
| 19 | { |
||
| 20 | return Attribute::make( |
||
| 21 | get: fn () => Markdown::convert($this->content) |
||
| 22 | ); |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Get the comment url. |
||
| 27 | * |
||
| 28 | * @return Attribute |
||
| 29 | */ |
||
| 30 | protected function commentUrl(): Attribute |
||
| 31 | { |
||
| 32 | return Attribute::make( |
||
| 33 | get: fn () => route('blog.comment.show', ['id' => $this->getKey()]) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 34 | ); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |