check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { $this->orderableModel = collect($this->route()->parameters()) ->first(fn($param) => $param instanceof Model); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'order' => [ 'required', 'integer', 'min:1', sprintf('max:%s', $this->orderableModel->max('order')), function ($attribute, $value, $fail) { /** @phpstan-ignore-next-line */ if ($this->orderableModel && intval($value) === $this->orderableModel->order) { $fail("La valeur de {$attribute} doit ĂȘtre diffĂ©rente de la valeur actuelle."); } }, ], ]; } }