feat: add rating and comement

This commit is contained in:
2026-05-20 12:19:10 +03:30
parent e446de79fd
commit 6f5224a5d9
11 changed files with 547 additions and 32 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
// app/Traits/HasComments.php
namespace App\Traits;
use App\Models\Comment;
trait HasComments
{
public function comments()
{
return $this->morphMany(Comment::class, 'commentable');
}
public function getLatestCommentsAttribute()
{
return $this->comments()->latest()->limit(5)->get();
}
public function getCommentsCountAttribute()
{
return $this->comments()->count();
}
}