35 lines
852 B
PHP
35 lines
852 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Video extends Model
|
|
{
|
|
use \Backpack\CRUD\app\Models\Traits\CrudTrait;
|
|
use HasFactory;
|
|
protected $guarded = [''];
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
static::deleting(function($obj) {
|
|
\Storage::disk('uploads')->delete($obj->image);
|
|
});
|
|
}
|
|
|
|
public function setVideoAttribute($value)
|
|
{
|
|
$attribute_name = "video";
|
|
$disk = config('backpack.base.root_disk_name');
|
|
$destination_path = "public/uploads/videos";
|
|
|
|
$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path, $fileName = null);
|
|
|
|
// return $this->attributes[$attribute_name]; // uncomment if this is a translatable field
|
|
|
|
}
|
|
|
|
}
|