smartystudio/laravelmenu
最新稳定版本:v0.1
Composer 安装命令:
composer require smartystudio/laravelmenu
包简介
Drag and drop menu generator for Laravel.
README 文档
README
An admin interface for Laravel to easily add, edit or remove Menus.
Install
- In your terminal:
composer require smartystudio/laravelmenu
Step 2 & 3 are optional if you are using laravel 5.5
- If your Laravel version does not have package autodiscovery then add the service provider to your config/app.php file:
SmartyStudio\LaravelMenu\MenuServiceProvider::class,
- Add facade in the file config/app.php (optional on laravel 5.5):
'Menu' => SmartyStudio\LaravelMenu\Facades\Menu::class,
- Publish the config file & run the migrations.
php artisan vendor:publish --provider="SmartyStudio\LaravelMenu\MenuServiceProvider"
- Configure (optional) in
config/laravelmenu.php:
- CUSTOM MIDDLEWARE: You can add you own middleware
- TABLE PREFIX: By default this package will create 2 new tables named "menus" and "menu_items" but you can still add your own table prefix avoiding conflict with existing table
- TABLE NAMES If you want use specific name of tables you have to modify that and the migrations
- Custom routes If you want to edit the route path you can edit the field
- Role Access If you want to enable roles (permissions) on menu items
- Run the database migrations:
php artisan migrate
DONE!
Menu Builder Usage Example - displays the builder
On your view blade file
@extends('app') @section('contents') {!! Menu::render() !!} @endsection
You must have jQuery loaded before menu scripts
@push('scripts') {!! Menu::scripts() !!} @endpush
Using the Model
Call the model class:
use SmartyStudio\LaravelMenu\Models\Menu; use SmartyStudio\LaravelMenu\Models\MenuItem;
Menu Usage Example (a)
A basic two-level menu can be displayed in your blade template.
Using Model class
// Get menu by ID $menu = Menu::find(1); // Get menu by Name $menu = Menu::where('name','Test Menu')->first(); /** * Get menu by Name and the Items with eager loading. * This is RECOMENDED for better performance and less query calls. */ $menu = Menu::where('name','Test Menu')->with('items')->first(); // Get menu by ID $menu = Menu::where('id', 1)->with('items')->first(); // Access by Model result $public_menu = $menu->items; // Convert it to Array $public_menu = $menu->items->toArray();
Using Helper class
// Using Helper $public_menu = Menu::getByName('Public'); // return array
Menu Usage Example (b)
Now inside your blade template file, place the menu using this simple example:
<div class="nav-wrap"> <div class="btn-menu"> <span></span> </div><!-- // mobile menu button --> <nav id="mainnav" class="mainnav"> @if($public_menu) <ul class="menu"> @foreach($public_menu as $menu) <li class=""> <a href="{{ $menu['link'] }}" title="">{{ $menu['label'] }}</a> @if( $menu['child'] ) <ul class="sub-menu"> @foreach( $menu['child'] as $child ) <li class=""><a href="{{ $child['link'] }}" title="">{{ $child['label'] }}</a></li> @endforeach </ul><!-- /.sub-menu --> @endif </li> @endforeach <!-- empty --> @endif </ul><!-- /.menu --> </nav><!-- /#mainnav --> </div><!-- /.nav-wrap -->
HELPERS
Get Menu Items By Menu ID
use SmartyStudio\LaravelMenu\Facades\Menu; ... /** * Parameter: Menu ID * Return: Array */ $menuList = Menu::get(1);
Get Menu Items By Menu Name
In this example, you must have a menu named Admin
use SmartyStudio\LaravelMenu\Facades\Menu; ... /** * Parameter: Menu ID * Return: Array */ $menuList = Menu::getByName('Admin');
Customization of the menu
You can publish and edit the menu layout in resources/views/vendor/smartystudio/laravelmenu/menu.blade.php
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
// TODO
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email us instead of using the issue tracker.
Credits
- Martin Nestorov - Web Developer @ Smarty Studio.
- All Contributors
License
The SmartyStudio\LaravelMenu is open-source software licensed under the MIT license.
smartystudio/laravelmenu 适用场景与选型建议
smartystudio/laravelmenu 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「admin」 「menu」 「bootstrap」 「cms」 「crud」 「builder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 smartystudio/laravelmenu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smartystudio/laravelmenu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 smartystudio/laravelmenu 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Symfony extension to get active class base on current bundle/controller/action
2lenet/EasyAdminPlusBundle
Analysis module for finding problematical shop data.
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Selectize Theme for Bootstrap 4
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-05