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
+15 -2
View File
@@ -8,7 +8,8 @@ class Comment extends Model
{
protected $fillable = [
'user_id',
'media_id',
'commentable_id',
'commentable_type',
'content',
];
@@ -17,8 +18,20 @@ public function user()
return $this->belongsTo(User::class);
}
public function commentable()
{
return $this->morphTo();
}
// For backward compatibility with Media
public function media()
{
return $this->belongsTo(Media::class);
return $this->belongsTo(Media::class, 'commentable_id')->where('commentable_type', Media::class);
}
// For Music
public function music()
{
return $this->belongsTo(Music::class, 'commentable_id')->where('commentable_type', Music::class);
}
}