kineticamobile/atrochar
Composer 安装命令:
composer require kineticamobile/atrochar
包简介
Menu Generator for Laravel Apps - Populate menus in your views using Database backed Menus with @menu Blade component
README 文档
README
Menu Generator for Laravel Apps - Populate menus in your views using Database backed Menus with @menu Blade component
Installation
- Via Composer
$ composer require kineticamobile/atrochar
- Add trait to your User model.
use Kineticamobile\Atrochar\Traits\MenuAbilities; class User extends Authenticatable { use MenuAbilities;
- Run migrations
$ php artisan migrate
Simple Usage
Create Menus and its items
You can access the Menu Management in your app "APP_URL/atrochar/menus"
or add link wherever you want
<a href="{{ route('atrochar.menus.index') }}"> {{ __('Menus') }} </a>
Add a created menu in your views with blade component
- Using menu name
@menu("Dasboard")
- Using menu id
@menu(1)
- Using menu object
$menu = Menu::find(1); [...] @menu($menu)
Use views instead of programatic approach
You can publish the views of the components
$ php artisan vendor:publish --tag=atrochar.views
You have two views in resources/views/vendors/atrochar, default.blade.php nad jetstream.blade.php
To use these views see examples below
-
@menuview($menu)usedefault -
@menuview($menu, 'jetstream')usejetstream
Advanced Usage
Change Prefix of Package Routes
Publish configuration
$ php artisan vendor:publish --tag=atrochar.config
Modify conf/atrochar.php field prefix. It allows empty string, if null atrochar would be used.
Change iframe routes
Usually iframe links are in route atrochar/i/24
You can change i for whatever you want in conf/atrochar.php field iframe after publish the configuration file
$ php artisan vendor:publish --tag=atrochar.config
Restrict access to menu management
By default all users can manage menus.
You need to add the method canManageMenus() to your user model:
/** * @return bool */ public function canManageMenus() { // For example return $this->hasRole('Admin'); }
Use of the links' permission field
By default all items can be viewed. But you can add permission in your links, if not empty this ability is checked against the User method canViewMenuItem($ability)
You need to add the method canViewMenuItem($ability) to your user model to extend this behavior:
/** * @return bool */ public function canViewMenuItem($ability) { // For example return $this->getAllPermissions()->pluck('name')->contains($ability); }
Style your menus using themes or overriding default values
Using themes. Publish the config file in your app. In config/atrochar.php you can modify default values or add new themes
$ php artisan vendor:publish --tag=atrochar.config
return [ "defaultTheme" => [ "linkTag" => "a", "class" => "", "activeClass" => "", "listStartTag" => "<ul>", "listEndTag" => "</ul>", "itemStartTag" => "<li>", "itemEndTag" => "</li>", ], "themes" => [ "jetstream" => [ "linkTag" => "a", "class" => "inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out", "activeClass" => "inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out", "listStartTag" => "", "listEndTag" => "", "itemStartTag" => "", "itemEndTag" => "", ] ] ];
Once you've created a theme you can pass a string as a second argument in the @menu component the name of the theme
@menu("Dasboard", "jetstream")
If you pass an array as second argument the values override the defaultTheme values
@menu($menu, ["class" => "bg-gray-500 font-mono"])
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
Licence
MIT
kineticamobile/atrochar 适用场景与选型建议
kineticamobile/atrochar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 90 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「menu」 「laravel」 「blade」 「Atrochar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kineticamobile/atrochar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kineticamobile/atrochar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kineticamobile/atrochar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Symfony extension to get active class base on current bundle/controller/action
Yii2 DynaTree Menu widget uses Dynamic tree view control jquery.dynatree.js
Alfabank REST API integration
Create simple top navigation for laravel
Simple Object oriented menus for Symfony.
Filter Eloquent
统计信息
- 总下载量: 90
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-18