/** * model boot method */ protected static function boot() { parent::boot(); /** * model saved method * * @param $model */ parent::saved(function ($model) { if (Request::has('roles')) { $roles = is_string(Request::get('roles')) ? explode(',', Request::get('roles')) : (!Request::get('roles') || Request::get('roles') == 0 ? [] : Request::get('roles')); $model->roles()->sync($roles); } }); /** * model deleted method * * @param $model */ parent::deleted(function ($model) { $file = new FileRepository(config('laravel-user-module.user.uploads')); $file->deleteDirectories($model); }); /** * model deleted method * * @param $model */ parent::deleting(function ($model) { }); }