If - else does not work in laravel blade template
My question is that I have a page as a Laravel blade template. If the user is logged in, my page needs to be extended from the main layout. If the user is not logged in, my page needs to be extended from a different layout.
But my if-else statement doesn't work
<?php
if (Auth::check()){?>
@extends('layouts.outside');
<?php } else{ ?>
@extends('layouts.admin');
<?php }?>
I also tried the if-else blade version as follows:
@if (Auth::check())
@extends('layouts.outside')
@else
@extends('layouts.admin')
@endif
It didn't work either. Each time the expression is true or false, the block in the if and else statement runs one after the other. Since not, if otherwise. I mean every time it calls layouts.outside once once and just the bottom of it, the same page is loaded again from layouts.outside, no matter if the user is logged in or not.
thank
+3
source to share