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