<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

class CarouselSlide extends Model
{
    protected $fillable = ['image', 'title', 'subtitle', 'order', 'is_active'];

    protected static function booted(): void
    {
        static::deleting(function (CarouselSlide $slide) {
            if ($slide->image) {
                Storage::disk('public')->delete($slide->image);
            }
        });
    }
}
