feat: add many playlist for music

This commit is contained in:
2026-06-01 00:40:32 +03:30
parent 695efcc452
commit b3a7edf3a5
8 changed files with 162 additions and 51 deletions
+6 -5
View File
@@ -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
{