Elasticsearch uses ISO 8601 datetime format by default, but I believe you can change that from the config.
Laravel inconsistent timestamps format for User model on Logout
Hi 👋,
I use Elasticsearch driver (babenkoivan/elastic-scout-driver) for Laravel Scout.
I noticed a weird issue, when a user tries to logout from my Laravel Application.
Laravel updates the remember_token, which results in Scout updating the data as well on Elasticsearch.
But, on that update Laravel sets $user->timestamps to false which disables the casting for created_at and updated_at fields.
This code: https://github.com/laravel/framework/blob/f7c57c47f677b3fcfa1c70c6c3c51d0f90866d31/src/Illuminate/Auth/EloquentUserProvider.php#L99
Which eventually leads to inconsistant format for the timestamp fields.
Usually the format is like this: 2023-09-05T18:23:38.000000Z
But, on that instance (when Laravel updates the remember_token) the format is like this: 2023-09-05 18:23:38
Is it a bug?
As a workaround, for now I'm thinking of overriding the toSearchableArray method to do a check If the timestamp fields are not Carbon instance, then manually create the Carbon instance.
Please or to participate in this conversation.