Hi,
I believe I found a bug on the dashboard app. I'm trying to dynamically load dashboards of the same type. One for each site the current user has access to:
protected function dashboards()
{
$user = Auth::user()->id;
$dashboards = [
"Overview Board" => overviewBoard::create()->icon("fa fa-user"),
];
$resourceBoards = [];
foreach($user->sites->sortBy('name') as $site) {
$resourceBoards[$site->name] = resourceBoard::create('resourceBoard_' . $site->id)
->icon("fa fa-user")->params([
"site_id" => $site->id,
]);
}
if (count($resourceBoards) > 1) {
$dashboards["Resource Boards"] = Group::create()->icon("fa fa-list-alt")->sub($resourceBoards);
} elseif (count($resourceBoards) == 1) {
$dashboards["Resource Board"] = $resourceBoards[0];
}
return $dashboards;
}
If a user has access to more than one site, this function should give me a menu item called "Resource Boards" which, when clicked gives me the option to select my resourceBoard for each site. The menu is created correctly and as expected, but whenever I click on the menu items for the sites, only the first dashboard is loaded.
I.e. if I click 'UK' or 'USA' the 'UAE' dashboard gets loaded, as it is the first in the list.
Is this a bug or am I doing an obvious mistake?
Thanks
Christian