Answer the question
In order to leave comments, you need to log in
How to implement record counter in Laravel, AdminLTE?
Good day to all.
The project uses AdminLTE as an admin panel (package - jeroennoten/laravel-adminlte).
It is necessary in the menu, opposite the item, to write also the number of records in the
Ads database (5)
But the menu is written there in the config file
[
'text' => 'Объявления',
'url' => 'admin/offers',
'icon' => 'far fa-fw fa-file',
'label' => 5,
'label_color' => 'success',
]
DB::table('offers')->where('new',true)->count();
Answer the question
In order to leave comments, you need to log in
Everything, I figured it out myself.
For those who ever have this problem.
It is necessary to remove such menu items from the config and add them to the
AppServiceProvider
public function boot(Dispatcher $events)
{
$events->listen(BuildingMenu::class, function (BuildingMenu $event) {
$event->menu->add('MAIN NAVIGATION');
$event->menu->add([
'text' => 'Объявления',
'url' => 'admin/offers',
'icon' => 'far fa-fw fa-file',
'label' => DB::table('offers')->where('new',true)->count(),
'label_color' => 'success',
]);
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question