新增每日签到与补签卡功能
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:前台每日签到补签请求校验。
|
||||
*
|
||||
* 校验补签日期和房间参数,确保用户只能补签历史漏签日期。
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* 类功能:校验用户在签到日历中提交的补签请求。
|
||||
*/
|
||||
class MakeupDailySignInRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 方法功能:允许已登录用户提交补签请求。
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回补签请求的校验规则。
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'target_date' => ['required', 'date', 'before:today', 'after_or_equal:'.Carbon::today()->startOfMonth()->toDateString()],
|
||||
'room_id' => ['nullable', 'integer', 'exists:rooms,id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回补签请求的中文错误提示。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'target_date.required' => '请选择要补签的日期。',
|
||||
'target_date.date' => '补签日期格式不正确。',
|
||||
'target_date.before' => '只能补签今天之前的漏签日期。',
|
||||
'target_date.after_or_equal' => '补签卡只能补签本月的未签到日期。',
|
||||
'room_id.exists' => '当前聊天室不存在,请刷新页面后再补签。',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user