PHP code example of music-man-hl / administrator
1. Go to this page and download the library: Download music-man-hl/administrator library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
music-man-hl / administrator example snippets
'providers' => [
Forone\Admin\Providers\ForoneServiceProvider::class
]
'aliases' => [
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
'Entrust' => Zizaco\Entrust\EntrustFacade::class
]
return [
'site_config' => [
'site_name' => '站点名称',
'title' => '站点标题',
'description' => '站点描述',
'logo' => '站点logo地址'
],
'RedirectAfterLoginPath' => 'admin/roles', // 登录后跳转页面
'RedirectIfAuthenticatedPath' => 'admin/roles', // 如果授权后直接跳转到指定页面
'menus' => [
'系统设置' => [
'icon' => 'mdi-toggle-radio-button-on', //菜单icon
'permission' => 'admin', //菜单显示所需权限
'children' => [ //菜单的子菜单数组
'角色管理' => [
'uri' => 'roles', //菜单对应的uri
],
'权限管理' => [
'uri' => 'permissions',
],
'管理员管理' => [
'uri' => 'admins',
]
],
],
],
'qiniu' => [
'host' => 'http://share.u.qiniudn.com', //your qiniu host url
'access_key' => '-S31BNj77Ilqwk5IN85PIBoGg8qlbkqwULiraG0x', //for test
'secret_key' => 'QoVdaBFZITDp9hD7ytvUKOMAgohKaB8oa11FJdxN', //for test
'bucket' => 'share'
]
];
Route::group(['prefix' => 'admin', 'middleware' => ['admin.auth', 'admin.permission:admin']], function () {
function __construct()
{
parent::__construct('admins', '管理员');
$this->middleware('admin.permission:admin|test'); //需要admin及test的权限才可以访问该Controller
}
'columns' => [
['流水号', 'id', function ($id) {
return '';
}],
['金额', 'amount'],
['操作', 'buttons', 100, function () {
$buttons = [
['查看']
];
return $buttons;
}],
]
{!! Html::list_header([
'new'=>true,
'search'=>true,
'title'=>'数据列表标题',
'filters'=>$results['filters']
]) !!}
$results['filters'] = [
'status' => [
['label' => '所有状态', 'value'=>''],
['label' => '状态1', 'value' => 0]
],
'other' => [
['label' => '其它过滤', 'value'=>''],
['label' => '过滤1', 'value' => 0]
}
];
$all = $request->except(['page']);
$paginate = Model::orderBy('id', 'desc');
//如果没有筛选条件直接返回分页数据
if (!sizeof($all)) {
$paginate = $paginate->paginate();
}else{
//遍历筛选条件
foreach ($all as $key => $value) {
if ($key == 'keywords') { //检索的关键词,定义检索关键词的检索语句
$paginate->where('name', 'LIKE', '%'.$value.'%');
}else{
//可以根据不同的检索条件的不同值进行不同的语句组合,比如状态为7的数据加多筛选条件
if ($key == 'status' && $value == 7) {
$paginate->where($key, '=', 1)
->where('time', '<', Carbon::now())
->whereRaw(' `a` > `b` ')
->orWhere($key, '=', $value);
} else { //正常来说就只加where即可
$paginate->where($key, '=', $value);
}
}
}
$paginate = $paginate->paginate();
}
$results = [
'items' => $paginate->appends($all),
];
Form::form_select('type_id', '标的类型', [
['label'=>'名称', 'value'=>'']
],0.5,false)
{!! Form::form_radio('risk_level', '风险等级', [
[0, 'A', true],
[1, 'B'],
[2, 'C'],
[3, 'D'],
[4, 'E'],
[5, 'F']
], 0.5) !!}
{!! Form::form_time('time','开始时间','如 2015-06-06 08:00:00') !!}
{!! Form::form_date('date','开始日期','如 2015-06-06') !!}
{!! Form::form_text('column','字段名称','提示文字') !!}
{!! Form::form_area('column','字段名称','提示文字') !!}
{!! Form::single_file_upload('field_name', 'label') !!}
{!! Form::multi_file_upload('field_name', 'label') !!}
{!! Form::ueditor('name', 'label') !!}
php artisan vendor:publish
php artisan forone:init