This document explains how menu and menu items are managed in the Laravel Starter application.
The application uses a hierarchical menu system where:
- Menus are containers that define where navigation appears (e.g., sidebar, header, footer)
- Menu Items are the individual links, dropdowns, and navigation elements within each menu
Admin Dashboard
└── Menus (Index)
├── View Menu (Show)
│ ├── Menu Details
│ └── Menu Items List (nested display)
│ ├── Add Menu Item
│ ├── Edit Menu Item
│ ├── Delete Menu Item
│ └── View Menu Item
└── Create/Edit Menu
Menu items are managed through their parent menu, not as a standalone resource. This provides:
- ✅ Better UX - see all menu items in context of their menu
- ✅ Clearer hierarchy - understand parent-child relationships
- ✅ Simplified navigation - one less top-level menu item
- ✅ Contextual operations - all actions relate to the current menu
GET /admin/menus - List all menus
POST /admin/menus - Create new menu
GET /admin/menus/create - Show create form
GET /admin/menus/{id} - Show menu details with items
GET /admin/menus/{id}/edit - Edit menu
PUT /admin/menus/{id} - Update menu
DELETE /admin/menus/{id} - Delete menu
POST /admin/menuitems - Create new menu item
GET /admin/menuitems/create?menu_id=X - Show create form
GET /admin/menuitems/{id} - Show menu item details
GET /admin/menuitems/{id}/edit - Edit menu item
PUT /admin/menuitems/{id} - Update menu item
DELETE /admin/menuitems/{id} - Delete menu item
Note: There is no /admin/menuitems index route. Menu items are viewed through the menu show page.
- Navigate to Admin → Menus
- Click on a menu to view its details
- The menu show page displays:
- Menu information (name, location, status)
- Complete list of menu items with hierarchy
- Actions for each menu item
- Go to the menu show page
- Click "Add Item" or "Add Menu Item" button
- Fill in the menu item details
- Submit the form
- You'll be redirected back to the parent menu's show page
- From the menu show page, click the edit icon (✏️) on any menu item
- Update the menu item details
- Submit the form
- You'll be redirected back to the parent menu's show page
- From the menu show page, click the delete icon (🗑️) on any menu item
- Confirm the deletion
- Menu items with children cannot be deleted until children are removed
MenuItemsController changes:
- ✅ Removed
index()andindex_data()methods - ✅ Updated
store()to redirect to parent menu show page - ✅ Updated
update()to redirect to parent menu show page - ✅ Kept
create(),show(),edit(),destroy()methods
web.php changes:
// Menu Items routes - index excluded
Route::resource("menuitems", "$controller_name")->except(['index']);menu_data.json changes:
- ✅ Removed standalone "Menu Items" navigation link
- ✅ Menu items are accessed through their parent menu
Breadcrumbs updated:
- Menu Item Create:
Menus → Menu Details → Create Menu Item - Menu Item Edit:
Menus → Menu Details → Edit Menu Item - Previously:
Menu Items → Create/Edit(incorrect context)
Menu items are displayed hierarchically with:
- Indentation showing nesting level
- Icons if specified
- Child count badges for parent items
- Type badges (Link, Dropdown, Divider, etc.)
- Status indicators (Active, Visible, Published)
- Action buttons (View, Edit, Delete)
Menu items are always viewed in the context of their parent menu, making it clear which menu they belong to.
Users don't need to navigate to a separate page to see menu items. Everything is in one place.
The nested display with indentation makes parent-child relationships immediately clear.
Fewer top-level navigation items mean less cognitive load for administrators.
The flow is intuitive:
- Find the menu
- View its items
- Add/edit items directly
If you're upgrading from a version with standalone menu items:
- Bookmarks: Update any bookmarked
/admin/menuitemsURLs to/admin/menus - Documentation: Update internal docs to reflect the new workflow
- Training: Inform users that menu items are now managed through menus
- Permissions: The
view_menuspermission covers both menus and menu items
If you need programmatic access to all menu items:
use Modules\Menu\Models\MenuItem;
// Get all menu items
$allMenuItems = MenuItem::all();
// Get menu items for a specific menu
$menuItems = MenuItem::where('menu_id', $menuId)->get();
// Get hierarchical structure
$menu = Menu::with('items.children')->find($menuId);Potential improvements to consider:
- Drag-and-drop reordering of menu items
- Bulk operations on menu items
- Menu item templates for common patterns
- Visual menu builder with live preview
- Import/export menu structures
For questions or issues with menu management:
- Check the existing menus in the database
- Review the menu item relationships
- Verify permissions are correctly set
- Check the application logs for errors