22
33namespace App \Models ;
44
5+ use App \Models \Concerns \Approvable ;
6+ use App \Models \Concerns \HasAuthor ;
57use Illuminate \Database \Eloquent \Builder ;
68use Illuminate \Database \Eloquent \Factories \HasFactory ;
79use Illuminate \Database \Eloquent \Model ;
1416
1517class Comment extends Model
1618{
17- use Chartable, HasFactory, Likeable, SoftDeletes;
19+ use Chartable, HasFactory, Likeable, SoftDeletes, Approvable, HasAuthor ;
1820
1921 /**
2022 * The attributes that are mass assignable.
@@ -67,16 +69,6 @@ public function parent()
6769 return $ this ->belongsTo (static ::class, 'parent_id ' );
6870 }
6971
70- /**
71- * Verify if the current comment is approved.
72- *
73- * @return bool
74- */
75- public function isApproved (): bool
76- {
77- return $ this ->attributes ['approved ' ] === 1 || $ this ->attributes ['approved ' ] === true ;
78- }
79-
8072 /**
8173 * Verify if the current comment is a reply from another comment.
8274 *
@@ -97,28 +89,6 @@ public function hasReplies(): bool
9789 return count ($ this ->replies ) > 0 ;
9890 }
9991
100- /**
101- * Get the author of the comment.
102- *
103- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
104- */
105- public function author (): BelongsTo
106- {
107- return $ this ->belongsTo (User::class, 'user_id ' );
108- }
109-
110- /**
111- * Where clause for only approved comments.
112- *
113- * @param Builder $query
114- *
115- * @return Builder
116- */
117- public function scopeApproved (Builder $ query ): Builder
118- {
119- return $ query ->where ('approved ' , 1 );
120- }
121-
12292 /**
12393 * Convert URLs in text to HTML links.
12494 *
0 commit comments