Add Profile Comment Search (Livewire)

This commit is contained in:
2026-01-10 18:55:47 +01:00
parent 7810cd53fb
commit cfd6af59fb
5 changed files with 178 additions and 60 deletions

View File

@@ -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());
}
/**