validate([ 'start_date' => ['nullable', 'date_format:Y-m-d', 'required_with:end_date'], 'end_date' => ['nullable', 'date_format:Y-m-d', 'required_with:start_date', 'after_or_equal:start_date'], ]); $today = date('Y-m-d'); $startDate = $params['start_date'] ?? $today; $endDate = $params['end_date'] ?? $today; return $this->success(FundsSummaryService::summary($startDate, $endDate)); } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage()); } } }