Crud: Support 1-1 relationships

Created on 20 Nov 2016  路  14Comments  路  Source: Laravel-Backpack/CRUD

Right now Backpack does support 1-1 relationships. It's generally preferred to NOT move columns away from the parent table, because it saves a JOIN, but some people prefer it, because it's more object-oriented.

Since Laravel supports them, Backpack should too.

Here's one solution for it: https://gist.github.com/ChrisThompsonTLDR/c83b21a6f7c9041b680be880c2a21ff0

Next step: figure out best way to do it (syntax) and implement the solution.

Feature urgent

Most helpful comment

@tabacitu is there any news? I want to help if possible :)

All 14 comments

I don't understand what's going on 馃槀

So if you have a model, say Product (id, name, price, discount, author). Instead of storing everything in the "products" table, some prefer to split it up into multiple tables:

  • products (id, name, author_id)
  • product_details (product_id, price, discount, description)

It sounds absurd for such a small table, but when one table would have 20-30 columns, it kind of makes sense.

One product has one detail. So it's a 1-1 relationship. Backpack currently has no easy way to handle that, the only way is having mutators for each detail attribute.

Ah okay yes, I understand this now :D

Nice! Almost give up searching on backpack for almost two weeks to find if this is already existed on backpack... haha

Backpack currently has no easy way to handle that, the only way is having mutators for each detail attribute.

Are the mutators you are talking about, eloquent model mutators? or does backpack have its own mutators?

I have a polymorphic relation. Many of my resources have an App\Address. I would like to update the address from the App\User edit page. This issue also includes this situation (polymorphic one to one), correct?

@scottgrayson , yup, we're talking about standard eloquent mutators. And yes, this feature will also fix the polymorphic 1-1). I expect it to be done by the end of the week, as it's quite a bummer I forgot to include the easiest relationship of them all :-)

Cheers!

Hi!
I kind of followed that conversation and have a similar problem where I am not sure of how to solve it...

Imagine a table users (user_id etc) and another one called pictures. Each picture is assigned to a single user and there is no way that a picture is moved to another user. Also there are plenty of pictures for each user, which should be sortable.
So the problem is this - how do I implement a nice, smart way where I as admin can go to the user and then view all pictures assigned to him, and eventually sort them? As I said, there is no use case where the pictures change the user and viewing a list of all pictures does not make any sense...

Any way to solve this? Is this included in the request above?

What is the status of this issue? In december you said it would be there within a week. I am willing to help if you could give an explanation of the current situation.

Hi all, is there any news about this important works??
Thanks!

Bump! I need this!

@tabacitu is there any news? I want to help if possible :)

Any news on this?

Hi, you checkout the pull request for this issue. It's still in review but it's close to being done.

Thank you @tumf87 . Let's close this issue and move the conversation in your PR, if needed.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexanderWM picture AlexanderWM  路  3Comments

packytagliaferro picture packytagliaferro  路  3Comments

sseggio picture sseggio  路  3Comments

genesiscz picture genesiscz  路  3Comments

M0H3N picture M0H3N  路  3Comments