1 | <?php |
||
13 | class Post extends Model |
||
14 | { |
||
15 | use Translatable, MediaRelation, PresentableTrait; |
||
16 | |||
17 | public $translatedAttributes = ['title', 'slug', 'content']; |
||
18 | protected $fillable = ['category_id', 'status', 'title', 'slug', 'content']; |
||
19 | protected $table = 'blog__posts'; |
||
20 | protected $presenter = PostPresenter::class; |
||
21 | protected $casts = [ |
||
22 | 'status' => 'int', |
||
23 | ]; |
||
24 | |||
25 | public function category() |
||
29 | |||
30 | public function tags() |
||
34 | |||
35 | /** |
||
36 | * Get the thumbnail image for the current blog post |
||
37 | * @return File|string |
||
38 | */ |
||
39 | public function getThumbnailAttribute() |
||
49 | |||
50 | /** |
||
51 | * Check if the post is in draft |
||
52 | * @param Builder $query |
||
53 | * @return bool |
||
54 | */ |
||
55 | public function scopeDraft(Builder $query) |
||
59 | |||
60 | /** |
||
61 | * Check if the post is pending review |
||
62 | * @param Builder $query |
||
63 | * @return bool |
||
64 | */ |
||
65 | public function scopePending(Builder $query) |
||
69 | |||
70 | /** |
||
71 | * Check if the post is published |
||
72 | * @param Builder $query |
||
73 | * @return bool |
||
74 | */ |
||
75 | public function scopePublished(Builder $query) |
||
79 | |||
80 | /** |
||
81 | * Check if the post is unpublish |
||
82 | * @param Builder $query |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function scopeUnpublished(Builder $query) |
||
89 | |||
90 | /** |
||
91 | * @param $method |
||
92 | * @param $parameters |
||
93 | * @return mixed |
||
94 | */ |
||
95 | public function __call($method, $parameters) |
||
110 | } |
||
111 |