3
I’m having trouble setting and picking up items from a sessão
, in this case I am setting which page should mark in the menu as active
.
In the __contruct
of mine controller
I’m doing like this:
public function __construct()
{
$this->middleware('auth');
session()->put('pagina', 'I');
}
And on my pages where the menu is like this:
<li {{((Session('pagina') == 'H')? 'class="active"' : '')}}>
<a href="/"><i class="zmdi zmdi-home"></i> Home</a>
</li>
<li {{((Session('pagina') == 'C')? 'class="active"' : '')}}>
<a href="/igrejas"><i class="zmdi zmdi-assignment-account"></i> Igreja</a>
</li>
<li {{((Session('pagina') == 'I')? 'class="active"' : '')}}>
<a href="/celulas"><i class="zmdi zmdi-accounts-alt"></i> {{ (($igreja->FLG_MODEL_IGREJ == 'C')? 'Celulas' : (($igreja->FLG_MODEL_IGREJ == 'P')? 'Pequenos Grupos' : 'Salas dominicais' )) }}</a>
</li>
But the menu is not coming marked, I gave a dd
in Session
and it’s coming back null
, what to do ?
I tried to add also in functions of my controller and also had no success as in the example below:
public function index(){
session()->put('pagina', 'I');
if(Auth::user()->FLG_USUAR_MASTE == 1) {
return view('aa');
}else{
return view('aa');
}
}