mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 15:57:50 +08:00
fix : update path And request
This commit is contained in:
79
app/Request/Admin/AdminRoleRequest.php
Normal file
79
app/Request/Admin/AdminRoleRequest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use App\Common\Trait\HttpMethodTrait;
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class AdminRoleRequest extends FormRequest
|
||||
{
|
||||
use HttpMethodTrait;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:60',
|
||||
'code' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:60',
|
||||
'regex:/^[a-zA-Z0-9_]+$/',
|
||||
],
|
||||
'status' => 'sometimes|integer|in:1,2',
|
||||
'sort' => 'required|integer',
|
||||
'remark' => 'nullable|string|max:255',
|
||||
'permissions' => 'sometimes|array',
|
||||
'permissions.*' => 'string|exists:menu,name',
|
||||
];
|
||||
if ($this->isCreate()) {
|
||||
$rules['code'][] = 'unique:role,code';
|
||||
}
|
||||
if ($this->isUpdate()) {
|
||||
$rules['code'][] = 'unique:role,code,' . $this->route('id');
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'code',
|
||||
'name',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
],
|
||||
'create' => [
|
||||
'code',
|
||||
'name',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
],
|
||||
'batch_grant_permission' => [
|
||||
'permissions',
|
||||
'permissions.*',
|
||||
]
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user