The dd stands for "dump and die" so before being able to perform a logout the parser has been allready stopped ('died').
@36864 thanks so much. it works now. I will flag it as solved. bUT I noticed another funny behaviour with the app...I am trying to use the auth middleware to protect my posts, so in the postController constructor, i passed in this to it:
$this->middleware('auth');
but i noticed when i am not signed it, it generates an error saying Route[login] not defined. but when I am signed in and click link to Posts...it works fine.
it is redirects you to /login but you login page is/auth/login
@DevFromRotterdam thanks for the info. @rin4ik thanks..it worked but i noticed a funny behaviour in the PostController;When i am not logged it and i try to click on the link to Posts, it generates a Route[login] not defined error. But when i AM logged in, it goes to the expected page. i DID this in the __construct method
$this->middleware('auth');
change method in Illuminate\Foundation\Exceptions\Handler.php;
protected function unauthenticated($request, AuthenticationException $exception)
{
return $request->expectsJson()
? response()->json(['message' => $exception->getMessage()], 401)
: redirect('/auth/login');
}
@bbmattieu9 you haven't specified route name in your login route.
simple way change your route instead of changing handler class it will work as expected. add 'as'=>'login'
Route::get('auth/login',[ 'uses' => 'Auth\LoginController@getLogin', 'as '=>'login' ]);
The auth middleware will throw an UnauthenticatedException when the user isn't authenticated, which your exception handler will handle by default by redirecting the user to the login route, which you have not defined.
You can change the redirection route in app\Exceptions\Handler.php
@bbmattieu9 you are welcome
@DevFromRotterdam @rin4ik @36864 Is dd() almost the same with using var_dump in OOPHP?? Seem like it will be helpful for debugging. Where can I read more bout it. So as to know when to apply it to check whatever needs to be checked.
@bbmattieu9 yes it is exactly the same . it means die and dump the result. here you go http://laraveldaily.com/echoing-dd-vs-var_dump-vs-print_r/
Please or to participate in this conversation.