Edit File: Admin.php
<?php namespace App\Models; use App\Traits\Uploadable; use App\Traits\UploadTrait; use Illuminate\Notifications\Notifiable; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; class Admin extends Authenticatable { use Notifiable, SoftDeletes , Uploadable ; protected $fillable = [ 'name', 'phone', 'email', 'password', 'avatar', 'role_id', 'is_notify', 'blocked', ]; protected $hidden = [ 'password', ]; public function getAvatarAttribute() { return asset('assets/uploads/admins/' . $this->attributes['avatar']); } public function setAvatarAttribute($value) { if (null != $value) { $this->attributes['avatar'] = $this->uploadFile($value, 'admins'); } } public function role() { return $this->belongsTo(Role::class)->withTrashed(); } public function setPasswordAttribute($value) { if (null != $value) { $this->attributes['password'] = bcrypt($value); } } public function replays() { return $this->morphMany(ComplaintReplay::class, 'replayer'); } public static function boot() { parent::boot(); /* creating, created, updating, updated, deleting, deleted, forceDeleted, restored */ self::deleted(function ($model) { $model->deleteFile($model->attributes['avatar'], 'admins'); }); } }
Back to File Manager