diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index e4bcd813425f..7cdaef87e810 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -147,9 +147,7 @@ protected function compareDates($attribute, $value, $parameters, $operator) } if ($format = $this->getDateFormat($attribute)) { - return $this->checkDateTimeOrder( - $format, $value, $this->getValue($parameters[0]) ?: $parameters[0], $operator - ); + return $this->checkDateTimeOrder($format, $value, $parameters[0], $operator); } if (! $date = $this->getDateTimestamp($parameters[0])) { @@ -194,11 +192,13 @@ protected function getDateTimestamp($value) */ protected function checkDateTimeOrder($format, $first, $second, $operator) { - $first = $this->getDateTimeWithOptionalFormat($format, $first); + $firstDate = $this->getDateTimeWithOptionalFormat($format, $first); - $second = $this->getDateTimeWithOptionalFormat($format, $second); + if (! $secondDate = $this->getDateTimeWithOptionalFormat($format, $second)) { + $secondDate = $this->getDateTimeWithOptionalFormat($format, $this->getValue($second)); + } - return ($first && $second) && ($this->compare($first, $second, $operator)); + return ($firstDate && $secondDate) && ($this->compare($firstDate, $secondDate, $operator)); } /**