svoydom/app/Models/Slider.php

32 lines
626 B
PHP
Raw Permalink Normal View History

2023-05-17 09:57:20 +03:00
<?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);
}
});
}
}