<?php

namespace App\Models;

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

class Slider extends Model
{
    use HasFactory;

    const FILE_PATH = '/admin/images/sliders/';

    protected $fillable=['image','url'];

    public static function boot()
    {
        parent::boot();
        /**
         * Write code on Method
         *
         * @return response()
         */
        
        static::deleting(function($item){
            if(file_exists(self::FILE_PATH.$item->image)){
                unlink(self::FILE_PATH.$item->image);
            }
        });
    }
}
