feat: add music feature
This commit is contained in:
+19
-8
@@ -5,23 +5,34 @@
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
class Music extends Model
|
||||
{
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'music';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'title',
|
||||
'artist',
|
||||
'file_path',
|
||||
'type', // public or private
|
||||
'image_id',
|
||||
'user_id', 'title', 'artist', 'file_path', 'type',
|
||||
'playlist_id', 'image_id', 'duration', 'order', 'is_active'
|
||||
];
|
||||
protected $casts = [
|
||||
'duration' => 'string',
|
||||
'order' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// Relation to user (optional)
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
public function playlist(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MusicPlaylist::class, 'playlist_id');
|
||||
}
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tag::class, 'music_tag');
|
||||
}
|
||||
|
||||
protected $appends = ['url', 'image_url'];
|
||||
// Accessor for full URL
|
||||
public function getUrlAttribute()
|
||||
|
||||
Reference in New Issue
Block a user