File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 44
55use App \User ;
66use App \Models \Like ;
7+ use Illuminate \Database \Eloquent \Relations \MorphMany ;
78
89trait HasLikes
910{
@@ -24,12 +25,12 @@ public function dislikedBy(User $user)
2425 optional ($ this ->likes ()->where ('user_id ' , $ user ->id )->get ()->first ())->delete ();
2526 }
2627
27- public function likes ()
28+ public function likes (): MorphMany
2829 {
2930 return $ this ->morphMany (Like::class, 'likeable ' );
3031 }
3132
32- public function isLikedBy (User $ user )
33+ public function isLikedBy (User $ user ): bool
3334 {
3435 if ($ user == null ) {
3536 return false ;
@@ -38,7 +39,7 @@ public function isLikedBy(User $user)
3839 return $ this ->likes ()->where ('user_id ' , $ user ->id )->exists ();
3940 }
4041
41- public function getLikesCountAttribute ()
42+ public function getLikesCountAttribute (): int
4243 {
4344 return $ this ->likes ->count ();
4445 }
You can’t perform that action at this time.
0 commit comments