first commit
This commit is contained in:
31
app/Models/Slider.php
Executable file
31
app/Models/Slider.php
Executable file
@ -0,0 +1,31 @@
|
||||
<?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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user