laravel-learn-bbs/config/administrator/roles.php

79 lines
1.7 KiB
PHP
Raw Normal View History

2018-06-02 08:28:28 +00:00
<?php
/**
* Created by PhpStorm.
* User: xing
* Date: 2018/6/2
* Time: 16:08
*/
use Spatie\Permission\Models\Role;
return [
'title' => '角色',
'single' => '角色',
'model' => Role::class,
'permission' => function () {
return Auth::user()->can('manage_users');
},
'columns' => [
'id' => [
'title' => 'ID',
],
'name' => [
'title' => '标识'
],
'permissions' => [
'title' => '权限',
'output' => function ($value, $model) {
$model->load('permissions');
$result = [];
foreach ($model->permissions as $permission) {
$result[] = $permission->name;
}
return empty($result) ? 'N/A' : implode($result, ' | ');
},
'sortable' => false,
],
'operation' => [
'title' => '管理',
'output' => function ($value, $model) {
return $value;
},
'sortable' => false,
],
],
'edit_fields' => [
'name' => [
'title' => '标识',
],
'permissions' => [
'type' => 'relationship',
'title' => '权限',
'name_field' => 'name',
],
],
'filters' => [
'id' => [
'title' => 'ID',
],
'name' => [
'title' => '标识',
]
],
// 新建和编辑时的表单验证规则
'rules' => [
'name' => 'required|max:15|unique:roles,name',
],
// 表单验证错误时定制错误消息
'messages' => [
'name.required' => '标识不能为空',
'name.unique' => '标识已存在',
]
];