<?php

namespace App\Models;

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

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

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