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 | ]; |
||
48 | |||
49 | /** |
||
50 | * The attributes that should be mutated to dates. |
||
51 | * |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $dates = [ |
||
55 | 'edited_at' |
||
56 | ]; |
||
57 | |||
58 | /** |
||
59 | * The "booting" method of the model. |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | protected static function boot() |
||
77 | |||
78 | /** |
||
79 | * Return the field to slug. |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | public function slugStrategy(): string |
||
87 | |||
88 | /** |
||
89 | * Return the count cache configuration. |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | public function countCaches(): array |
||
100 | |||
101 | /** |
||
102 | * Get the category that owns the thread. |
||
103 | * |
||
104 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
105 | */ |
||
106 | public function category() |
||
110 | |||
111 | /** |
||
112 | * Get the user that owns the thread. |
||
113 | * |
||
114 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
115 | */ |
||
116 | public function user() |
||
120 | |||
121 | /** |
||
122 | * Get the comments for the thread. |
||
123 | * |
||
124 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
125 | */ |
||
126 | public function comments() |
||
130 | |||
131 | /** |
||
132 | * Get the solved comment of the thread. |
||
133 | * |
||
134 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
135 | */ |
||
136 | public function solvedComment() |
||
140 | |||
141 | /** |
||
142 | * Get the last comment of the thread. |
||
143 | * |
||
144 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
145 | */ |
||
146 | public function lastComment() |
||
150 | |||
151 | /** |
||
152 | * Get the user that edited the thread. |
||
153 | * |
||
154 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
155 | */ |
||
156 | public function editedUser() |
||
160 | } |
||
161 |