Add Profile Comment Search (Livewire)
This commit is contained in:
@@ -89,9 +89,17 @@ class User extends Authenticatable
|
||||
/**
|
||||
* Has Many Comments.
|
||||
*/
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Comment Count.
|
||||
*/
|
||||
public function commentCount(): int
|
||||
{
|
||||
return DB::table('comments')->where('commenter_id', $this->id)->count();
|
||||
return cache()->remember('userComments' . $this->id, 300, fn() => $this->comments->count());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user