50 lines
1.0 KiB
PHP
50 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 文件功能:前台每日签到日历查询请求校验。
|
||
|
|
*
|
||
|
|
* 校验月份参数,供签到日历按月展示签到状态。
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 类功能:校验用户查询签到日历时传入的月份参数。
|
||
|
|
*/
|
||
|
|
class DailySignInCalendarRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 方法功能:允许已登录用户查询自己的签到日历。
|
||
|
|
*/
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return $this->user() !== null;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 方法功能:返回签到日历查询规则。
|
||
|
|
*
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'month' => ['nullable', 'date_format:Y-m'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 方法功能:返回签到日历查询的中文错误提示。
|
||
|
|
*
|
||
|
|
* @return array<string, string>
|
||
|
|
*/
|
||
|
|
public function messages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'month.date_format' => '月份格式不正确。',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|