-
-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default date field casts are ignored #1744
Comments
Hello @john-dent 👋🏻
Could you show us in code how you do that? |
Sure, something along the lines of the following in a custom cast: public function get($model, $key, $value, $attributes)
{
return [
'raw' => $value ?? null,
'formatted' => $value?->format('jS M Y G:i'),
'ago' => $value?->diffForHumans(),
];
} |
Specific issue appears to be in |
Readable / writable type for Laravels default date columns ignores any model casts.
Can be replicated by casting updated_at, created_at or deleted_at; you will notice larastan does not respect the cast.
Our specific use case is to return an array of formatted dates, larastan still expects the return type to be of Carbon|null.
I can create a PR for this issue that would first respect the cast and fallback to the default date format, if this is something that may be approved?
Many thanks,
The text was updated successfully, but these errors were encountered: