Hi Readers
Recently when I was working in Laravel, I came across an issue. It was regarding the selection of a particular layout as per the logged-in user. I have to show a particular layout according to the role of the user logged-in. When I used extends($layout) in if condition some how all the layout got included and hence I came out with an alternative solution.
To overcome the above stated problem follow the following procedure.
Syntax :-
<?php $layout = 'layouts.master'; ?>
@if(Auth::check())
@if(Auth::user()->role == 'ngo')
<?php $layout = 'layouts.ngo_master'; ?>
@elseif(Auth::user()->role == 'company')
<?php $layout = 'layouts.admin_master'; ?>
@endif
@endif
@extends($layout)
0 Comment(s)