58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Request\Admin;
|
|
|
|
use Hyperf\Validation\Request\FormRequest;
|
|
|
|
class EmployeeRequest 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 [
|
|
'account' => 'required|digits:11',
|
|
'chinese_name' =>'required|string',
|
|
'status' => 'required|in:1,2',
|
|
'role_id' => 'exists:admin_role,id',
|
|
'avatar' => '',
|
|
'limit' => 'required|integer',
|
|
'section_id' => 'exists:admin_section,id',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'account.required' => '账号必填',
|
|
'account.digits' => '账号格式错误',
|
|
'chinese_name.required' => '名称必填',
|
|
'status.required' => '状态必填',
|
|
'status.in' => '状态值错误',
|
|
'role_id.exists' => '角色不存在',
|
|
// 'avatar.required' => '头像必填',
|
|
'limit.required' => 'limit必填'
|
|
];
|
|
}
|
|
|
|
protected array $scenes = [
|
|
'add' => ['account','chinese_name','status','role_id','avatar'],
|
|
'edit' => ['id','account','chinese_name','status','role_id','avatar'],
|
|
'del' => ['id'],
|
|
'reset_password' => ['id'],
|
|
'info' => ['id'],
|
|
'list' => ['limit'],
|
|
];
|
|
}
|