I'm having trouble setting and grabbing items from a sessão
, in this case I'm setting which page should I mark in the menu as active
.
No __contruct
of my controller
I'm doing this:
public function __construct()
{
$this->middleware('auth');
session()->put('pagina', 'I');
}
And on my pages where the menu looks 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 the Session
and it is returning null
, what to do?
I also tried to add functions in my controller and I was not successful 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');
}
}