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 DiscussPostPresenter |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Get the content parsed in HTML. |
||
| 14 | * |
||
| 15 | * @return Attribute |
||
| 16 | */ |
||
| 17 | protected function contentMarkdown(): Attribute |
||
| 18 | { |
||
| 19 | return Attribute::make( |
||
| 20 | get: fn () => Markdown::convert($this->content) |
||
| 21 | ); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Get the post url. |
||
| 26 | * |
||
| 27 | * @return Attribute |
||
| 28 | */ |
||
| 29 | protected function postUrl(): Attribute |
||
| 30 | { |
||
| 31 | return Attribute::make( |
||
| 32 | get: fn () => route('discuss.post.show', ['id' => $this->getKey()]) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 33 | ); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |