gearbox-solutions / eloquent-filemaker

A Model extension and Eloquent driver for Laravel connecting to FileMaker through the Data API
https://gearboxgo.com
MIT License
54 stars 16 forks source link

Issues with date format when trying to update #40

Closed lgebing closed 1 year ago

lgebing commented 1 year ago

Hi, I am having issues updating from version 0.2.7 to 0.2.8 or anything higher due to the modification to the date cast handling.

For reference: https://github.com/gearbox-solutions/eloquent-filemaker/compare/0.2.7...0.2.8

This change removed a condition from the following section: https://github.com/gearbox-solutions/eloquent-filemaker/blob/c7d6f253477997a86e199d6a82961af65d181d92/src/Database/Eloquent/FMModel.php#L488-L491

This leads to the model only returning for example 2023-02-23 when using a format like Y-m-d H:i:s, regardless of the cast specified on the model (in my case I'm using datetime).

Smef commented 1 year ago

Can you give me an example of what you're trying to do? The part you've highlighted from the source is for writing dates to the FileMaker database. Dates in FileMaker can't have time, so they're stripped out before writing to the database. the latest 1.0 version still does this.

The casting is for getting the data out of the database into an object. The Y-m-d H:i:s format part is for the format for sending the object to the front-end as JSON. A date field should be cast as a date and not a datetime since there isn't any time data there.

What is the source field you're trying to cast?

Smef commented 1 year ago

Never mind. I think I see the issue. I've just pushed up v1.0.1 with a fix for this. You'll probably want to upgrade your dependency to gearbox-solutions/eloquent-filemaker instead of bluefeather/eloquent-filemaker and you should be able to install this new version.