route('o')); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { //dd(request()->post()); return [ 'stop_at'=> [ 'required', 'date', 'after:today', 'exclude_unless:extra_charges,null', function($attribute,$value,$fail) { if ($this->route('o')->cancel_date->greaterThan($value)) $fail(sprintf('Service cannot be cancelled before: %s',$this->route('o')->cancel_date->format('Y-m-d'))); } ], 'extra_charges_amount' => [ 'nullable', 'exclude_unless:extra_charges,null', function($attribute,$value,$fail) { if ($this->route('o')->cancel_date->greaterThan(request('stop_at')) && (request('extra_charges') !== 1)) $fail('Extra charges must be accepted if cancelling before contract end'); }, ], 'extra_charges' => 'sometimes|required|accepted', 'notes' => 'nullable|min:5', ]; } }