Skip to content
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

Formatting date on models to ISO 8601 gives error #109

Open
joelperry93 opened this issue Nov 6, 2016 · 2 comments
Open

Formatting date on models to ISO 8601 gives error #109

joelperry93 opened this issue Nov 6, 2016 · 2 comments

Comments

@joelperry93
Copy link

I'm trying to format the date properties on my models to conform to ISO 8601 by using the $dateFormat property on the model classes. When I override this property in the models, I get a "bad request" error on all requests

{
    "errors": [
        {
            "status": 400,
            "title": "Bad Request",
            "detail": "Request could not be served."
        }
    ]
}

Is modifying this property the best way to get ISO 8601? And how do I track down the actual issue here? There isn't anything in storage/logs/laravel.log. Is there a seperate log?

Thanks

@MichaelMNM
Copy link

I had an issue that may be related to this. I have to specify custom timestamps in my model. After a bit of digging I found where the UPDATED_AT field was being set in the JsonApiTrait.php I changed the line that sets the updated_at property in both put/patch ops to:

$data['attributes'][$model::UPDATED_AT] = Carbon::now()->format($model::getDateFormat());

Everything appears to be working on my end. I created a pull request.

@joelperry93
Copy link
Author

Cool, thanks! Would be good to see this merged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants