typicms/sidebar
最新稳定版本:1.0.1
Composer 安装命令:
composer require typicms/sidebar
包简介
A sidebar builder for TypiCMS
README 文档
README
This package is based on SpartnerNL/Laravel-Sidebar v1
Installation
Require this package in your composer.json and run composer update.
"typicms/sidebar": "~1.0.0"
After updating composer, add the ServiceProvider to the providers array in bootstrap/providers.php
'TypiCMS\Modules\Sidebar\SidebarServiceProvider::class',
To publish the default views use:
php artisan vendor:publish
Adding a menu
// Or use dependency injection $builder = app('TypiCMS\Modules\Sidebar\SidebarManager'); $builder->group('app', function ($group) { $group->addItem('dashboard', function($item) { // Route method automatically transforms it into a route $item->route('admin::dashboard'); // If you want to call route() yourself to pass optional parameters $item->route = route('admin::dashboard'); }); }
Groups
It’s possible to group the menu items. A little header will be rendered to separate the different menu items.
Adding items
The first parameter of $group->addItem() is the name. The name field will automatically be translated through the menu translation file. (e.g. menu.dashboard). If the translation does not exists, the given name will be displayed.
The second parameter is optionally a callback. Alternatively you can chain the methods.
You can change the route, name and icon. If you route given it will automatically be translated to acp.{$name}.index.
Without group headings
To disable rendering of the group headings, you can easily use $builder->withoutGroup(). Group headings will now be ignored.
Authorization
By default, all groups and items are public for all users. You can use ->authorized(false) on all these objects to disable them or use any condition you want.
Advanced usage
If you have multiple sidebars, you can extend the SidebarManager and register a new singleton:
class AdminSidebar extends SidebarManager { public function build($callback = null) { $this->group('application', function(SidebarGroup $group) { $group->addItem(...) }); } }
统计信息
- 总下载量: 982
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-18