Beispiel #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     // Get the first permission that is not this one that we are trying to delete
     $default_permission = Role::findOrFail(1);
     // Build users model based on Auth config model
     $user_model = config('auth.model');
     // Update all the users that have this role. Assign them the default role.
     $user_model::where('role_id', '=', $id)->update(['role_id' => $default_permission->id]);
     // Delete the requested role.
     $role = Role::findOrFail($id);
     $role->delete();
     return redirect()->action('\\Aginev\\Acl\\Http\\Controllers\\RoleController@index')->with('success', trans('acl::role.destroy.deleted'));
 }