feat: add rating and comement
This commit is contained in:
+15
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user