1 | <?php |
||
14 | class DiscussThread extends Model |
||
15 | { |
||
16 | use Countable, |
||
17 | Sluggable, |
||
18 | DiscussThreadPresenter, |
||
19 | HasMentionsTrait; |
||
20 | |||
21 | /** |
||
22 | * The attributes that are mass assignable. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $fillable = [ |
||
27 | 'user_id', |
||
28 | 'category_id', |
||
29 | 'title', |
||
30 | 'slug', |
||
31 | 'content', |
||
32 | 'content', |
||
33 | 'comment_count', |
||
34 | 'is_locked', |
||
35 | 'is_pinned', |
||
36 | 'is_solved', |
||
37 | 'is_edited' |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * The accessors to append to the model's array form. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $appends = [ |
||
46 | 'thread_url', |
||
47 | 'last_page' |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * The attributes that should be mutated to dates. |
||
52 | * |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $dates = [ |
||
56 | 'edited_at' |
||
57 | ]; |
||
58 | |||
59 | /** |
||
60 | * The "booting" method of the model. |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | protected static function boot() |
||
78 | |||
79 | /** |
||
80 | * Return the field to slug. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function slugStrategy(): string |
||
88 | |||
89 | /** |
||
90 | * Return the count cache configuration. |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | public function countCaches(): array |
||
101 | |||
102 | /** |
||
103 | * Get the category that owns the thread. |
||
104 | * |
||
105 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
106 | */ |
||
107 | public function category() |
||
111 | |||
112 | /** |
||
113 | * Get the user that owns the thread. |
||
114 | * |
||
115 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
116 | */ |
||
117 | public function user() |
||
121 | |||
122 | /** |
||
123 | * Get the comments for the thread. |
||
124 | * |
||
125 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
126 | */ |
||
127 | public function comments() |
||
131 | |||
132 | /** |
||
133 | * Get the solved comment of the thread. |
||
134 | * |
||
135 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
136 | */ |
||
137 | public function solvedComment() |
||
141 | |||
142 | /** |
||
143 | * Get the last comment of the thread. |
||
144 | * |
||
145 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
146 | */ |
||
147 | public function lastComment() |
||
151 | |||
152 | /** |
||
153 | * Get the user that edited the thread. |
||
154 | * |
||
155 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
156 | */ |
||
157 | public function editedUser() |
||
161 | } |
||
162 |