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