<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Gallery extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
        'image',
        'category',
        'sort_order',
        'is_active',
    ];

    protected $casts = [
        'is_active'  => 'boolean',
        'sort_order' => 'integer',
    ];

    // Scopes (commonly used in your controller)
    public function scopeActive($query)
    {
        return $query->where('is_active', true);
    }

    // Optional: if you want default sorting by sort_order
    protected static function booted()
    {
        static::addGlobalScope('order', function ($query) {
            $query->orderBy('sort_order');
        });
    }
}
