<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class SongSection extends Model
{
    use HasFactory;

    protected $fillable = [
        'song_id',
        'label_id',
        'order',
        'locked',
    ];

    protected function casts(): array
    {
        return [
            'order' => 'integer',
            'locked' => 'boolean',
        ];
    }

    public function song(): BelongsTo
    {
        return $this->belongsTo(Song::class);
    }

    public function label(): BelongsTo
    {
        return $this->belongsTo(Label::class);
    }

    public function slides(): HasMany
    {
        return $this->hasMany(SongSlide::class, 'song_section_id')->orderBy('order');
    }
}
