diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 4ef0f5314062..a9cd9700ca77 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -1475,6 +1475,20 @@ public function getDates() ] : []; } + /** + * Get all attributes that should be converted to dates including timestamps and user-defined. + * + * @return array + */ + public function getDateCastableAttributes(): array + { + $dateAttributes = array_filter( + array_keys($this->getCasts()), fn (string $key): bool => $this->isDateCastable($key) + ); + + return array_unique([...$dateAttributes, ...$this->getDates()]); + } + /** * Get the format for database stored dates. *