Reputation: 119
in my project i have front and back office.
I have this
InfoController
//unread messages
public function naoLido(){
$infos = PedidoInfo::where('lido',0)->get();
return view('layoutadmin' ,compact('infos'));
}
this works, but how can I use this in all pages? I have an layoutAdmin.blade.php where i had the menus and i want put the number or unread messages there like that, but i have in one page, how can i display in all pages?
<i class="glyphicon glyphicon-list"></i> Informações
@if ($infosL -> count() > 0)
{ $infosL -> count() }}
@endif
<span class="caret pull-right"></span>
Thanks
Upvotes: 2
Views: 1512
Reputation: 163938
You can use view composer for that.
View composers are callbacks or class methods that are called when a view is rendered. If you have data that you want to be bound to a view each time that view is rendered, a view composer can help you organize that logic into a single location.
Upvotes: 1