mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-12-25 19:04:34 -05:00
Don't allow navigating to dashboard pages for models that aren't listed in the menu
This commit is contained in:
parent
4abcbe879e
commit
e0ffe81e51
1 changed files with 26 additions and 1 deletions
|
@ -72,7 +72,32 @@ class Dashboard
|
|||
{
|
||||
$model_name = ucfirst($model);
|
||||
|
||||
if (file_exists(app_path() . '/Models/' . $model_name . '.php')) {
|
||||
// Ensure the model has been declared in the menu
|
||||
$model_in_menu = false;
|
||||
|
||||
foreach (self::$menu as $menu_item) {
|
||||
if (array_key_exists('submenu', $menu_item)) {
|
||||
// Check each item if this is a submenu
|
||||
foreach ($menu_item['submenu'] as $submenu_item) {
|
||||
if ($submenu_item['model'] == $model) {
|
||||
$model_in_menu = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Check the menu item
|
||||
if ($menu_item['model'] == $model) {
|
||||
$model_in_menu = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't bother continuing if we've already confirmed it's in the menu
|
||||
if ($model_in_menu) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($model_in_menu && file_exists(app_path() . '/Models/' . $model_name . '.php')) {
|
||||
$model_class = 'App\\Models\\' . $model_name;
|
||||
|
||||
if ($type != null && $type != $model_class::$dashboard_type) {
|
||||
|
|
Loading…
Reference in a new issue