feat: add many playlist for music
This commit is contained in:
@@ -20,12 +20,11 @@ class Music extends Model
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'user_id', 'title', 'artist', 'file_path', 'type',
|
||||
'playlist_id', 'image_id', 'duration', 'order', 'is_active'
|
||||
'user_id', 'title', 'artist', 'file_path', 'type',
|
||||
'image_id', 'duration', 'is_active'
|
||||
];
|
||||
protected $casts = [
|
||||
'duration' => 'integer',
|
||||
'order' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
protected $attributes = [
|
||||
@@ -36,9 +35,11 @@ public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
public function playlist(): BelongsTo
|
||||
public function playlists(): BelongsToMany
|
||||
{
|
||||
return $this->belongsTo(MusicPlaylist::class, 'playlist_id');
|
||||
return $this->belongsToMany(MusicPlaylist::class, 'music_playlist', 'music_id', 'playlist_id')
|
||||
->withPivot('order')
|
||||
->withTimestamps();
|
||||
}
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user