src/Controllers/UserController.php
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->expectsJson()) {
                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->expectsJson()) {
            return response()->json([$message], 200);
        }

        session()->flash('success', $message);
        return redirect()->route('users.index');
    }
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->expectsJson()) {
                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->expectsJson()) {
            return response()->json([$message], 200);
        }

        session()->flash('success', $message);
        return redirect()->route('users.index');
    }
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 -> expectsJson ( ) ) { 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 -> expectsJson ( ) ) { return response ( ) -> json ( [ $ message ] , 200 ) ; } session ( ) -> flash ( 'success' , $ message ) ; return redirect ( ) -> route ( 'users.index' ) ; }
Remove the specified user from storage.

@param  string  $hash
@return \Illuminate\Http\Response
Remove the specified user from storage .