1 | <?php namespace Modules\Blog\Entities; |
||
10 | class Post extends Model |
||
11 | { |
||
12 | use Translatable, MediaRelation, PresentableTrait; |
||
13 | |||
14 | public $translatedAttributes = ['title', 'slug', 'content']; |
||
15 | protected $fillable = ['category_id', 'status', 'title', 'slug', 'content']; |
||
16 | protected $table = 'blog__posts'; |
||
17 | protected $presenter = PostPresenter::class; |
||
18 | protected $casts = [ |
||
19 | 'status' => 'int', |
||
20 | ]; |
||
21 | |||
22 | public function category() |
||
26 | |||
27 | public function tags() |
||
31 | |||
32 | /** |
||
33 | * Check if the post is in draft |
||
34 | * @param Builder $query |
||
35 | * @return bool |
||
36 | */ |
||
37 | public function scopeDraft(Builder $query) |
||
41 | |||
42 | /** |
||
43 | * Check if the post is pending review |
||
44 | * @param Builder $query |
||
45 | * @return bool |
||
46 | */ |
||
47 | public function scopePending(Builder $query) |
||
51 | |||
52 | /** |
||
53 | * Check if the post is published |
||
54 | * @param Builder $query |
||
55 | * @return bool |
||
56 | */ |
||
57 | public function scopePublished(Builder $query) |
||
61 | |||
62 | /** |
||
63 | * Check if the post is unpublish |
||
64 | * @param Builder $query |
||
65 | * @return bool |
||
66 | */ |
||
67 | public function scopeUnpublished(Builder $query) |
||
71 | |||
72 | /** |
||
73 | * @param $method |
||
74 | * @param $parameters |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function __call($method, $parameters) |
||
92 | } |
||
93 |