8000 Support snake case relationships when these are specified · Issue #315 · cloudcreativity/laravel-json-api · GitHub
[go: up one dir, main page]

Skip to content
Support snake case relationships when these are specified #315
Closed
@JapSeyz

Description

@JapSeyz

Hi,

I was trying to save three belongsTo relationships, but for some reason only the first one would go through; While investing it, I dd'ed here https://github.com/cloudcreativity/laravel-json-api/blob/develop/src/Eloquent/AbstractAdapter.php#L370 and saw that it had fetched the relationship before saving, what's the idea behind this?

Eg. when trying to save a client_id on a user, this is the $record being passed to persist:

....{"client_id":1,"client":{"id":1,"currency":"EUR","name":"client-name"}}.

It seems like a redundant fetch from the database?

I also finally found my issue with only some of the relationships being saved, here: https://github.com/cloudcreativity/laravel-json-api/blob/develop/src/Adapter/AbstractResourceAdapter.php#L205

What's the idea behind Camelizing the method-name, when Laravel famously uses snake-case for relationships?

The package is absolutely wonderful, but I'll see if I can get a PR in with some documentation.

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0