1 | <?php |
||
14 | class Post extends Model |
||
15 | { |
||
16 | use PostAttributes, |
||
17 | IsAuthorable, |
||
18 | PostsHaveComments, |
||
19 | PostsHaveACategory; |
||
20 | |||
21 | public const PUBLISHED = 'published'; |
||
22 | public const DRAFT = 'draft'; |
||
23 | public const SCHEDULED = 'scheduled'; |
||
24 | |||
25 | protected $table = 'posts'; |
||
26 | |||
27 | protected $primaryKey = 'id'; |
||
28 | |||
29 | public $guarded = ['id']; |
||
30 | |||
31 | public $timestamps = true; |
||
32 | |||
33 | protected $appends = [ |
||
34 | 'tags_count', |
||
35 | 'statuses', |
||
36 | 'friendly_status', |
||
37 | 'view_path', |
||
38 | 'delete_path', |
||
39 | ]; |
||
40 | |||
41 | protected $dates = ['published_at']; |
||
42 | |||
43 | public function category() |
||
47 | |||
48 | public function comments() |
||
61 | |||
62 | public function approvedComments() |
||
66 | |||
67 | public function disapprovedComments() |
||
71 | |||
72 | public function guestComments() |
||
76 | |||
77 | public function userComments() |
||
81 | |||
82 | public function tags() |
||
86 | |||
87 | public function newEloquentBuilder($query) : PostBuilder |
||
91 | |||
92 | public function path() |
||
96 | |||
97 | public function setPublished() |
||
104 | |||
105 | public function setDrafted() |
||
112 | |||
113 | public function setScheduled($publish_date = null) |
||
124 | |||
125 | public function setStatus(string $status = null) |
||
145 | |||
146 | public function setSlug(string $title = null) |
||
154 | |||
155 | public function statuses() |
||
163 | |||
164 | public function getStatusesAttribute() |
||
168 | |||
169 | public function getFriendlyStatusAttribute() |
||
181 | |||
182 | public function getViewPathAttribute() |
||
190 | |||
191 | public function getDeletePathAttribute() |
||
199 | } |
||
200 |