芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/portpulselogistics.com/app/Models/User.php
'datetime', ]; /** * Revert avatar url. * @return string */ public function registerMediaCollections(): void { $this->addMediaCollection('avatar')->singleFile(); } public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('preview')->fit(Manipulations::FIT_CROP, 300, 300)->nonQueued(); } public function getAvatarImageAttribute() { return $this->getFirstMediaUrl('avatar') ? $this->getFirstMediaUrl('avatar') : asset('assets/lte/media/avatars/blank.png'); } /** * Revert user role. * @return string */ public function getUserRoleAttribute() { $user_roles = config('cms.user_roles'); $modules_file = json_decode(File::get(base_path('modules_statuses.json')), true); foreach($modules_file as $module) { if(is_array(config('module_'.strtolower($module).'.user_roles'))){ $user_roles = array_merge($user_roles, config('module_'.strtolower($module).'.user_roles')); } } $user_roles = array_merge($user_roles, config('module_cargo.user_roles')); return $user_roles[$this->role]; } /** * Observer locale. */ protected static function booted() { // when deleted user static::deleted(function ($user) { // remove avatar when deleted user if ($user->avatar && $user->avatar != null) { $user->deleteFile($user->avatar, self::DIRECTORY_IMAGE); } event(new UserDeletedEvent($user)); }); } public function getUsersOnly($query) { return $query->whereIn('role', [0,1]); } public function getAdminsOnly($query) { return $query->where('role', 1); } public function getStaffOnly($query) { return $query->where('role', 0); } public function getOthersOnly($query) { return $query->whereNotIn('role', [0,1]); } }