Exemplo n.º 1
0
 public function forceDelete(Request $request)
 {
     if ($request->has('user')) {
         try {
             $user = User::withTrashed()->findOrFail($request->input('user'));
             $user->forceDelete();
             flash()->overlay("The user and all associated data owned by the user have been deleted.  Remember, forms are owned by team, so any forms the user created will continue to exist.  Scores for judging, however, have been deleted", "User Deleted");
         } catch (\Exception $e) {
             dd($e);
             flash()->overlay('The profile cannot be deleted.  This is likely because the user owns an object that cannot be safely deleted or they are the only System Administrator.  The recommended course of action is to deactivate the profile, as this will prevent the user from signing-in, but will preserve the integrity of the system data.  If you must delete this user no matter what, you must manually inspect the database and determine why the row cannot be deleted (most likely a foreign key constraint would be violated).  You should consult the assistance of a database administrator.', 'Force Delete Failed');
         }
     } else {
         flash()->overlay('No user was specified', 'Reactivation Failed');
     }
     return redirect(action('UserController@index'));
 }