This is my menu array format in adminlte.php
'menu' => [
[
'text' => 'Dashboard',
'url' => '/dashboard',
'icon' => 'dashboard',
'label'=> $test // how to pass variable here or alternative way without using building menu
'label-color' => 'success'
],
],
How can I pass count variable to the label on runtime?
I knew there is a way to do it with building menu but, need to rebuild the whole thing inside adminlte.php . I need to pass count variable to it, if I put in adminlte.php, the variable will be undefined.
Can the building menu used to update the menu label or append the label and label-color into it?
Is there a method to override the current value in label by passing variable to it?
From Laravel-AdminLTE documentation:
It is also possible to configure the menu at runtime, e.g. in the boot of any service provider. Use this if your menu is not static, for example when it depends on your database or the locale. It is also possible to combine both approaches. The menus will simply be concatenated and the order of service providers determines the order in the menu.
To configure the menu at runtime, register a handler or callback for the MenuBuilding event, for example in the boot() method of a service provider:
use Illuminate\Contracts\Events\Dispatcher;
use JeroenNoten\LaravelAdminLte\Events\BuildingMenu;
class AppServiceProvider extends ServiceProvider
{
public function boot(Dispatcher $events)
{
$events->listen(BuildingMenu::class, function (BuildingMenu $event) {
$event->menu->add('MAIN NAVIGATION');
$event->menu->add([
'text' => 'Blog',
'url' => 'admin/blog',
]);
});
}
}
https://github.com/jeroennoten/Laravel-AdminLTE#menu-configuration-at-runtime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With