Laravel redirect issue from blade template
I am new to laravel 5. I am working on larvel page security and I need to prevent any page or url from opening but when I use {{ Redirect::to('/dashboard') }}
it does not work.
Please help me find a way use Redirect / Url
in laravel view (Blade template)
I have already tried :-
1. {{ url('/dashboard') }}
2. {{ Redirect::to('/dashboard') }}
Code :-
@if(Auth::user()->role_id == 1)
{{ 'Page' }}
@else
{{ Redirect::to('/dashboard') }}
@endif
Thanks everyone
source to share
Your question is difficult to understand, but I suppose you want to redirect the user in the view after checking if it is a login. I have bad news for you, the logic goes on the controller, not the views .
This means you need to check if the user is a login on the controller and after that you redirect to the correct view, on Laravel the most common way to do this is to create a middleware that checks if the user is a login and then apply the correct logic ...
You have many ways to do this, but first you have to understand how it works, you can check it out in the Laravel Authentication documentation.
source to share