Edit File: BaseModelHelpers.php
<?php namespace App\Models\Helpers; use App\Models\User; trait BaseModelHelpers { // accessors and mutators public function getImageAttribute() { if ($this->attributes['image']) { $image = $this->getImage($this->attributes['image'], static::IMAGEPATH); } else { $image = $this->defaultImage(static::IMAGEPATH); } return $image; } public function setImageAttribute($value) { if (null != $value && is_file($value)) { isset($this->attributes['image']) ? $this->deleteFile($this->attributes['image'], static::IMAGEPATH) : ''; $this->attributes['image'] = $this->uploadAllTypes($value, static::IMAGEPATH); } } // helpers protected function asJson($value) { return json_encode($value, JSON_UNESCAPED_UNICODE); } public static function boot() { parent::boot(); /* creating, created, updating, updated, deleting, deleted, forceDeleted, restored */ static::deleted(function ($model) { if (isset($model->attributes['image'])) { $model->deleteFile($model->attributes['image'], static::IMAGEPATH); } }); } }
Back to File Manager