redirect view with @if in laravel

2

I am trying to redirect to a view in laravel if the user fulfills a membership (membership = stage), but this only returns text to me instead of the view, my code is as follows:

@if (Auth::check())
   @if(Auth::user()->etapa == 1)
   @return view('welcome');
                    @else
                    <a href="{{ url('/login') }}">Login</a>
                        <a href="{{ url('/register') }}">Register</a>
                    @endif

@endif
    
asked by Abdiel Hernandez 14.06.2018 в 04:02
source

1 answer

2

Re-routings must be done in the controller part and not in the view.

if (Auth::check()){
   if(Auth::user()->etapa == 1){
      return view('welcome');   
   }
   else{
      return view('otra vista')
   }
}

In case you want to do something similar in the view you must include the html belonging, it can be done in several ways the most common and simple is with the function include() .

@if (Auth::check())
   @if(Auth::user()->etapa == 1)
     @include("welcome");
   @else
       <a href="{{ url('/login') }}">Login</a>
       <a href="{{ url('/register') }}">Register</a>
   @endif

@endif
    
answered by 14.06.2018 / 06:06
source