request->set('delete', 1); return parent::getValidatorInstance(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $array = [ 'delete' => 'sometimes', ]; $startDate = Carbon::createFromFormat('Y-m-d H:i:s', $this->vihar->start_date .' '. '00:00:00'); $todayDate = Carbon::createFromFormat('Y-m-d H:i:s', Carbon::now()->format('Y-m-d') .' '. '00:00:00'); $result = $todayDate->eq($startDate); if ($result) { $array['delete'] = [new DeleteVihar($this->vihar)]; } return $array; } protected function failedValidation(Validator $validator) { if (Request::wantsJson()) { throw new HttpResponseException(response()->json(['message' => $validator->errors()->first(), 'error' => true, 'status' => 422], 422)); } else { throw new ValidationException($validator); } } /** * Get the validation rules that apply to the request. * * @return array */ public function messages() { return [ 'start_time.after' => 'Please enter a time after the current time.', ]; } }