feat: add music feature
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MusicCategory extends Model
|
||||
{
|
||||
protected $table = 'music_categories';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'description', 'image_id', 'order', 'is_active'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'order' => 'integer',
|
||||
];
|
||||
|
||||
public function playlists(): HasMany
|
||||
{
|
||||
return $this->hasMany(MusicPlaylist::class, 'category_id');
|
||||
}
|
||||
|
||||
public function image(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Image::class);
|
||||
}
|
||||
|
||||
public function getActivePlaylistsAttribute()
|
||||
{
|
||||
return $this->playlists()->where('is_active', true)->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user