check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { $this->ticket = $this->route('ticket'); $max = Ticket::query()->where('site_id', $this->ticket->site_id)->max('order'); $this->merge([ 'priority' => min($this->integer('priority'), $max) ]); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'priority' => [ 'required', 'integer', 'min:1', function ($attribute, $value, $fail) { if ($this->ticket && intval($value) === $this->ticket->order) { $fail("La valeur de {$attribute} doit ĂȘtre diffĂ©rente de la valeur actuelle."); } }, ], ]; } }