<?php

namespace AleshaCMS\Models\CMS;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Slider extends Model
{
    protected $fillable = ['name', 'slug', 'autoplay', 'interval'];

    protected $casts = ['autoplay' => 'boolean'];

    public function slides(): HasMany
    {
        return $this->hasMany(SliderSlide::class)->orderBy('sort_order');
    }

    public function activeSlides(): HasMany
    {
        return $this->slides()->where('is_active', true);
    }
}
