I am new in laravel 5 .
I am working on larvel page security and i have to prevent open some page or Url
but when i use {{ Redirect::to('/dashboard') }}
in view it is not working .
Please help me to find a way to use Redirect / Url
in laravel view (Blade template)
I have already tried :-
{{ url('/dashboard') }}
{{ Redirect::to('/dashboard') }}
Code :-
@if(Auth::user()->role_id == 1)
{{ 'Page' }}
@else
{{ Redirect::to('/dashboard') }}
@endif
In Laravel, you can do something like this: <a href="{{ Request::referrer() }}">Back</a> (assuming you're using Blade).
By default laravel will redirect a user to the home page like so: protected $redirectTo = '/home'; To change that default behaviour, add the following code in App/Http/Controllers/Auth/LoginController. php . This will redirect users (after login) to where ever you want.
Open the command prompt or terminal based on the operating system you are using and type the following command to create controller using the Artisan CLI (Command Line Interface). Replace the <controller-name> with the name of your controller. This will create a plain constructor as we are passing the argument — plain.
Use a JavaScript redirect instead:
@if(Auth::user()->role_id == 1)
{{ 'Page' }}
@else
<script>window.location = "/dashboard";</script>
@endif
@if(your conditions)
@php
header("Location: " . URL::to('/'), true, 302);
exit();
@endphp
@endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With