check(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'delivery_status' => [ 'required', new EnumIsValidRule(DeliveryStatus::class), // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed function ($attribute, $value, $fail) { $deliveryStatus = DeliveryStatus::make(\intval($this->delivery_status)); if ($this->order->delivery_status->value > $deliveryStatus->value) { $fail(trans(':attribute Il n\'est pas possible de revenir en arrière sur le statut')); return; } if ($deliveryStatus->value - $this->order->delivery_status->value !== 1) { $fail(trans(':attribute Il n\'est possible de modifier le statut que sur le statut suivant')); return; } } ] ]; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes() { return [ 'delivery_status' => trans('Statut de livraison') ]; } }