Inheritance: implements Cartalyst\Sentinel\Users\UserRepositoryInterface, use trait Cartalyst\Support\Traits\EventTrait, use trait Cartalyst\Support\Traits\RepositoryTrait
 /**
  * Remove the specified user from storage.
  *
  * @param  string  $hash
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     // Fetch the user object
     //$id = $this->decode($hash);
     $user = $this->userRepository->findById($id);
     // Remove the user
     $user->delete();
     // All done
     $message = "{$user->email} has been removed.";
     if ($request->ajax()) {
         return response()->json([$message], 200);
     }
     session()->flash('success', $message);
     return redirect()->route('users.index');
 }
Example #2
0
 /**
  * Remove the specified user from storage.
  *
  * @param  string  $hash
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     // Fetch the user object
     //$id = $this->decode($hash);
     $user = $this->userRepository->findById($id);
     // Check to be sure user cannot delete himself
     if (Sentinel::getUser()->id == $user->id) {
         $message = "You cannot remove yourself!";
         if ($request->ajax()) {
             return response()->json($message, 422);
         }
         session()->flash('error', $message);
         return redirect()->route('users.index');
     }
     // Remove the user
     $user->delete();
     // All done
     $message = "{$user->email} has been removed.";
     if ($request->ajax()) {
         return response()->json([$message], 200);
     }
     session()->flash('success', $message);
     return redirect()->route('users.index');
 }