FehriJawher's avatar

@extends Test

Hi, i wanted to do a test for wich template i will use depending on user role ..

so i did this

@if($_SESSION["role"] == 'Superviseur') @extends('layouts.superviseur') @elseif($_SESSION["role"] == 'administrateur') @extends('layouts.master') @endif

in this case all the templates are included in the same time

i tried to break after each @extends a i get this error

Cannot break/continue 1 level

Help me please

0 likes
5 replies
tisuchi's avatar

I believe its a issue with your session, that @shakti mentioned.

User laravel session and write your code as follows-

@if($request->session()->has('role'))
    @if($request->session()->get('role') == 'Superviseur')
        @extends('layouts.superviseur') 
    @elseif
        @extends('layouts.master') 
    @endif
@endif
1 like
Screenbeetle's avatar

Sorry just a quick thought - have you checked that the logged in user doesn't have two roles? Superviseur & administrateur

1 like
FehriJawher's avatar
FehriJawher
OP
Best Answer
Level 1

@Screenbeetle i asked this question because i have 4 types of sidebar navigation one for Superviser one for admin .. etc .. i found a solution .. instead of creating 4 templates i did my test in the sidebar itself .. if the session role is admin then charge admin sidebar elements

  • .. etc .. something like that

    @if(Session::get('role') == 'administrateur') "li" blabla "/li" @if(Session::get('role') == 'superviseur') "li" bla bla "/li"

    and it works great :)

    thank you all for helping me

  • Please or to participate in this conversation.