refactor:拆分 API 路由与请求校验,统一 final 类和代码风格
This commit is contained in:
44
app/Http/Requests/Admin/AdminLoginRequest.php
Normal file
44
app/Http/Requests/Admin/AdminLoginRequest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 管理员登录请求。
|
||||
*
|
||||
* @see LoginController
|
||||
*/
|
||||
final class AdminLoginRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'account' => ['required', 'string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u'],
|
||||
'password' => ['required', 'string', 'max:256'],
|
||||
'captcha_key' => ['required', 'string', 'uuid'],
|
||||
'captcha_code' => ['required', 'string', 'max:32'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'account' => 'account',
|
||||
'password' => 'password',
|
||||
'captcha_key' => 'captcha_key',
|
||||
'captcha_code' => 'captcha_code',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user