{"id":16461873,"url":"https://github.com/salahhusa9/laravel-menu","last_synced_at":"2025-09-07T00:33:11.110Z","repository":{"id":143547072,"uuid":"615265934","full_name":"salahhusa9/laravel-menu","owner":"salahhusa9","description":"This is a useful package for building menus in your Laravel application, and it can help simplify the process of creating and managing menus in your application.","archived":false,"fork":false,"pushed_at":"2025-03-14T18:02:32.000Z","size":132,"stargazers_count":15,"open_issues_count":9,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T19:21:53.716Z","etag":null,"topics":["laravel","menu","menu-generator","php"],"latest_commit_sha":null,"homepage":"https://salahhusa9.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salahhusa9.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-17T10:07:22.000Z","updated_at":"2025-02-03T15:41:46.000Z","dependencies_parsed_at":"2023-03-25T23:48:26.653Z","dependency_job_id":"75b0b498-600d-4ec9-959e-2e3c36013feb","html_url":"https://github.com/salahhusa9/laravel-menu","commit_stats":{"total_commits":129,"total_committers":4,"mean_commits":32.25,"dds":0.2558139534883721,"last_synced_commit":"00b5df5379f8df9b277ff8f6028109cbf012ba5c"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salahhusa9%2Flaravel-menu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salahhusa9%2Flaravel-menu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salahhusa9%2Flaravel-menu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salahhusa9%2Flaravel-menu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salahhusa9","download_url":"https://codeload.github.com/salahhusa9/laravel-menu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243633483,"owners_count":20322608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","menu","menu-generator","php"],"created_at":"2024-10-11T11:09:43.002Z","updated_at":"2025-03-16T18:31:23.977Z","avatar_url":"https://github.com/salahhusa9.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Menu Generator\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/salahhusa9/laravel-menu.svg?style=flat-square)](https://packagist.org/packages/salahhusa9/laravel-menu)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/salahhusa9/laravel-menu/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/salahhusa9/laravel-menu/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![PHPStan Status](https://img.shields.io/github/actions/workflow/status/salahhusa9/laravel-menu/phpstan.yml?branch=main\u0026label=PHPStan\u0026style=flat-square)](https://github.com/salahhusa9/laravel-menu/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/salahhusa9/laravel-menu.svg?style=flat-square)](https://packagist.org/packages/salahhusa9/laravel-menu)\n\nThis is a useful package for building menus in your Laravel application, and it can help simplify the process of creating and managing menus in your application.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require salahhusa9/laravel-menu\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"menu-config\"\n```\n\nOptionally, you can publish the views using\n\n```bash\nphp artisan vendor:publish --tag=\"menu-views\"\n```\n\n## Usage\n\n### Basic\n\nYou can create menu in your application in any place you want, but the best place is in the AppServiceProvider.php file in the boot() method.\n\n```php\nuse SalahHusa9\\Menu\\Facades\\Menu;\n\npublic function boot()\n{\n    Menu::add('test', 'route.name', 'fa fa-home');\n}\n```\n\nAdd items to the menu using the add() method. You can chain multiple add() calls to add multiple items.\n\n```php\nMenu::add('test')\n    -\u003eadd('test2');\n```\n\nTo create a submenu, call addSubmenu() on a menu item and add items to the submenu using the add() method.\n\n```php\nMenu::add('test')\n    -\u003eadd('test2')\n    -\u003eaddSubmenu('test3', function ($submenu) {\n        $submenu-\u003eadd('test4');\n    })\n    -\u003eadd('test5');\n```\n\n### Blade\n\nTo render the menu, use the `\u003cx-menu /\u003e` blade component.\n\n```html\n\u003cx-menu /\u003e\n```\n\n### Customization of the menu\n\nIcons can be added to the menu items by passing the icon parameter to the add() method.\n\n```php\nMenu::add('test', 'route.name', ['icon' =\u003e 'fa fa-home']);\n```\n\nYou can also add a id and class to the menu item by passing the id and class parameters to the add() method.\n\n```php\nMenu::add('test', 'route.name',['class' =\u003e 'customClass', 'id' =\u003e 'customId']);\n```\n\nYou can also add a target to the menu item by passing the target parameter to the add() method.\n\n```php\nMenu::add('test', 'route.name', ['target' =\u003e '_blank']);\n```\n\nYou can also add a badge to the menu item by passing the badgeClass and badgeName parameters to the add() method.\n\n```php\nMenu::add('test', 'route.name', ['badgeClass' =\u003e 'badge badge-success', 'badgeName' =\u003e 'New']);\n```\n\nYou can also\n\n```php\n// old:\nif (auth()-\u003euser()-\u003ecan('gateName')){\n    Menu::add('test', 'route.name');\n}\n// new:\nMenu::add('test', 'route.name', ['gateName' =\u003e 'gateName']);\n```\n\n### Customization of the menu view\n\nYou can customize the menu view by publishing the views using\n\n```bash\nphp artisan vendor:publish --tag=\"menu-views\"\n```\n\n### Multiple Menus\n\nYou can create multiple menus in your application:\n\n```php\n    Menu::make('sidebar', function ($menu) {\n        $menu-\u003eadd('test', 'route.name');\n    });\n\n    Menu::make('main', function ($menu) {\n        $menu-\u003eadd('test', 'route.name');\n    });\n```\n\nFor render the menu, use the `\u003cx-menu for=\"sidebar\" /\u003e` blade component.\n\n## Configuration of the defult menu Classes of Ul and Li and the active class\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"menu-config\"\n```\n\nand you can change the defult menu Classes of Ul and Li and the active class\n\n```php\nreturn [\n    \"ul_class\" =\u003e \"menu-inner py-1\", // default menu class\n    \"ul_sub_menu_class\" =\u003e \"menu-sub\", // default submenu class\n\n    \"li_class\" =\u003e \"menu-item\", // default menu item class\n    \"li_sub_menu_class\" =\u003e \"menu-item\", // default submenu item class\n    \"li_sub_menu_open_class\" =\u003e \"menu-item active open\", // default submenu item class when open\n\n    \"a_class\" =\u003e \"menu-link\", // default menu link class\n    \"a_sub_menu_class\" =\u003e \"menu-link menu-toggle\", // default submenu link class\n\n    \"icon_class\" =\u003e \"menu-icon\", // default menu icon class\n\n    \"li_active_class\" =\u003e \"active\", // default active class of li\n    \"a_active_class\" =\u003e \"active\", // default active class of a\n\n    \"badge_class\" =\u003e \"badge rounded-pill ms-auto\", // default badge class\n];\n```\n\n## Advanced\n\nEach Item accept this parames :\n\n```php\nadd(\n    $name,\n    $routeName = null,\n    $options = [],\n)\n\naddSubmenu(\n    $name,\n    callback $callbackOfSubmenu,\n    $options\n)\n```\n\nThere is other functions that you can used :\n\n```php\nMenu::getMenuAsJson(); // return the menu as json\nMenu::renderAsJson(); // return the menu as json\nMenu::renderAsHtml(); // return the menu as html\n```\n\n## Roadmap\n\nSee the [open issues](../../issues) for a list of proposed features (and known issues).\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n-   [salahhusa9](https://github.com/salahhusa9)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalahhusa9%2Flaravel-menu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalahhusa9%2Flaravel-menu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalahhusa9%2Flaravel-menu/lists"}