feat: add rating and comement
This commit is contained in:
+16
-3
@@ -8,17 +8,30 @@ class Rating extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'media_id',
|
||||
'rateable_id',
|
||||
'rateable_type',
|
||||
'stars',
|
||||
];
|
||||
|
||||
public function media()
|
||||
public function rateable()
|
||||
{
|
||||
return $this->belongsTo(Media::class);
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
// For backward compatibility with Media
|
||||
public function media()
|
||||
{
|
||||
return $this->belongsTo(Media::class, 'rateable_id')->where('rateable_type', Media::class);
|
||||
}
|
||||
|
||||
// For Music
|
||||
public function music()
|
||||
{
|
||||
return $this->belongsTo(Music::class, 'rateable_id')->where('rateable_type', Music::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user