shrft / laravel-admin-bar
将管理工具栏添加到您网站的首页。
v0.0.1
2019-02-01 10:01 UTC
Requires
- php: >= 7.0.0
- laravel/framework: >= 5.5.0
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^7.4
This package is auto-updated.
Last update: 2024-09-15 23:57:59 UTC
README
此包可以帮助您将WordPress-like的管理栏添加到您的Laravel应用程序中。管理栏是一个易于访问的工具栏,用于访问您的管理页面。
支持版本
- laravel/framework >= 5.5
安装
要安装laravel-admin-bar,请通过Composer要求它
composer require shrft/laravel-admin-bar
Composer完成后,运行以下命令
php artisan vendor:publish --provider="Shrft\AdminBar\AdminBarServiceProvider"
如果您访问您的页面,您已经拥有管理栏了!
基本用法
您可以通过名为adminbar.php
的配置文件来配置如何以及何时显示管理栏。如果您已经运行了上面的发布命令,您应该在config目录下已经有这个文件了。
以下是adminbar.php
的默认设置。您可以从该文件的文档块中了解如何配置管理栏。
return array( /** * * Change this to false to disable admin bar * * */ 'enabled'=>true, /** * * Please specify your admin pages' url so that Admin Bar does not show up in * your admin pages. * * The default is 'admin/*' * The pass is checked with Illuminate\Http\Request::is(). * * */ 'excludes' => 'admin/*', /** * * In order to show Admin Bar only for logged in admin users, * please specify how to tell if current visitor is logged in and also an admin * user. * * As a default, we just return true. * * */ 'is_admin' => function(){ // This is an example code. // // if( Auth::user() && Auth::user()->isAdmin()){ // return true; // } // return false; return true; }, /** * * Specify links to show on Admin Bar. * * */ 'menus' => array( ['title'=>'Admin Top', 'path'=>'/admin'], ['title'=>'Add a post', 'path'=>'/admin/post/new'], // you can pass callback to the path ['title'=>'Edit a post', 'path'=>function($request){ // this is an example of how you generate pass dynamically. if($request->is('post/*')){ $postid = $request->route('id'); return '/admin/post/edit/' . $postid; } // if you return false, this link is not displayed. return false; }], // pass an array to path for dropdown menu. ['title'=>'Drop Down', 'path'=>[ ['title'=>'Option1', 'path'=>'/path/to/option1'], ['title'=>'Option2', 'path'=>'/path/to/option2'] ] ], ), );
许可证
Laravel Admin Bar是开源软件,许可协议为MIT。