feat: add type static playlist
This commit is contained in:
@@ -8,17 +8,27 @@
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany; // ← Add this
|
||||
class MusicCategory extends Model
|
||||
{
|
||||
// Static type so playlist categories are tagged like media categories.
|
||||
public const TYPE = 'playlist';
|
||||
|
||||
protected $table = 'music_categories';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'description', 'image_id', 'order', 'is_active'
|
||||
];
|
||||
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'order' => 'integer',
|
||||
];
|
||||
|
||||
protected $appends = ['type'];
|
||||
|
||||
public function getTypeAttribute(): string
|
||||
{
|
||||
return self::TYPE;
|
||||
}
|
||||
|
||||
public function playlists(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(MusicPlaylist::class, 'music_category_playlist', 'category_id', 'playlist_id');
|
||||
|
||||
Reference in New Issue
Block a user