mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 11:22:10 +08:00
82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Request\Admin;
|
|
|
|
use Hyperf\Validation\Request\FormRequest;
|
|
|
|
class AdminUserRequest extends FormRequest
|
|
{
|
|
/**
|
|
* 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
|
|
{
|
|
return [
|
|
'username' => 'required|string|max:20',
|
|
'user_type' => 'required|integer',
|
|
'nickname' => ['required', 'string', 'max:60', 'regex:/^[^\s]+$/'],
|
|
'phone' => 'sometimes|string|max:12',
|
|
'email' => 'sometimes|string|max:60|email:rfc,dns',
|
|
'avatar' => 'sometimes|string|max:255|url',
|
|
'signed' => 'sometimes|string|max:255',
|
|
'status' => 'sometimes|integer',
|
|
'backend_setting' => 'sometimes|array|max:255',
|
|
'remark' => 'sometimes|string|max:255',
|
|
'password' => 'sometimes|string|min:6|max:20',
|
|
'role_codes' => 'required|array',
|
|
'role_codes.*' => 'string|exists:admin_role,code',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return parent::messages();
|
|
}
|
|
|
|
protected array $scenes = [
|
|
'update' => [
|
|
'username',
|
|
'user_type',
|
|
'nickname',
|
|
'phone',
|
|
'email',
|
|
'avatar',
|
|
'signed',
|
|
'status',
|
|
'backend_setting',
|
|
'remark',
|
|
'password',
|
|
],
|
|
'create' => [
|
|
'username',
|
|
'user_type',
|
|
'nickname',
|
|
'phone',
|
|
'email',
|
|
'avatar',
|
|
'signed',
|
|
'status',
|
|
'backend_setting',
|
|
'remark',
|
|
'password',
|
|
],
|
|
'batch_grant_role' => [
|
|
'role_codes',
|
|
'role_codes.*',
|
|
]
|
|
];
|
|
}
|