merge([ 'price' => removeRupiahFormatting($this->price), 'discount' => removeRupiahFormatting($this->discount), 'total' => removeRupiahFormatting($this->total), ]); } public function rules(): array { if (! $this->route()->named('manage.transaction.print')) { $rules = [ 'barber' => ['required', Rule::exists('users', 'id')], 'service' => ['required', Rule::exists('services', 'id')], 'customer' => ['required'], 'price' => ['required', 'numeric', 'min:0', 'max:999999.99'], 'discount' => ['required', 'numeric', 'min:0', 'max:999999.99'], 'total' => ['required', 'numeric', 'min:0', 'max:999999.99'], 'image' => ['nullable', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'], 'payment_method' => ['required', Rule::in(['1', '2', '3'])], ]; } if ($this->isMethod('post') || $this->route()->named('manage.transaction.print')) { $rules['showing_barber_name'] = ['required', Rule::in(['1', '2'])]; $rules['showing_cashier_name'] = ['required', Rule::in(['1', '2'])]; } return $rules; } protected function failedValidation(Validator $validator): void { $this->handleValidationFailure($validator); } }