帮我解决这个问题
$this->validate($request, [
'period_starts' => 'required|numeric|digits:4|min:2010|max:'.(date('Y')),
'period_ends' => 'required|numeric|digits:4|gt:period_starts',
]);
有没有办法验证 period_ends 大于 period_starts 但只有 max +2 不允许更多
帮我解决这个问题
$this->validate($request, [
'period_starts' => 'required|numeric|digits:4|min:2010|max:'.(date('Y')),
'period_ends' => 'required|numeric|digits:4|gt:period_starts',
]);
有没有办法验证 period_ends 大于 period_starts 但只有 max +2 不允许更多
$this->validate($request, [
'period_starts' => 'required|numeric|digits:4|min:2010|max:'.(date('Y')),
'period_ends' => 'required|numeric|digits:4|gt:period_starts|max:'.(($request->period_starts)+2)
]);
我认为您需要添加 2 两个 gt:period_starts 然后使用 before_or_equal:new period_starts 规则参考
https://laravel.com/docs/8.x/validation#rule-before-or-equal