yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.76k stars 858 forks source link

Ensure dates are not turned to arrays by processor #3163

Closed miken32 closed 3 months ago

miken32 commented 3 months ago

Resolves #3156 and lets the transformer deal with date formatting as intended.

yajra commented 3 months ago

@miken32 the patch is intended for Collection, right? I tried using an Eloquent model with a date but the serialization is still the same and returns something like 2024-08-11T10:23:57.000000Z where the expectation is 2024-08-11 10:23:57.

miken32 commented 3 months ago

The update was to the helper class so I would have expected it to apply to both, but I was unable to check with a query builder instance as easily. Looking closer, I wonder if it's exiting Helper::convertToArray() early due to that first code block looking for ignore_getters?

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

yajra commented 3 months ago

The patch only applies to collection/array data sources.

For Eloquent, it is converted to an array thus making the model date serializer take effect. This explains why we still get 2024-08-11T10:23:57.000000Z when using an eloquent data source.

yajra commented 3 months ago

Release on https://github.com/yajra/laravel-datatables/releases/tag/v11.1.4, 🚀 Thanks!