Dynamic items in the navigation panel obtained from the database
Hello, good day, I would like to get help with a solution, I need to create items in the navigation dynamically according to records of an entity obtained from DB, I've been trying in the panel->navegationItems([]), but I need these items to be validated according to the user role, when I call the logged user I get null.
->navigationItems([
...$this->getDynamicNavigationItems()
])
public function getDynamicNavigationItems()
{
$items = DinamicReport::where('status', 'activo')
->get()
// ->filter(fn ($report) => $user->hasRole($report->role->name))
->map(fn ($report) =>
NavigationItem::make($report->name)
// ->url(route('dashboard.viewer', ['slug' => $report->slug]))
->url('/administrador/reportes/'.$report->slug)
->icon('heroicon-o-presentation-chart-line')
->group('Reportes embebidos')
// ->visible(auth()->user()->hasRole($report->role->name))
)
->values()
->all();
// dd($items);
return $items;
}
0 Replies