One to Many relations #723
-
I'm struggling to get the URLs for a one to many relation to work as it would within a normal Laravel deployment. I have a customer model which has a one to many relation to the address model. I have attempted to amend the CRUD::setRoute() but it's not working, ideally the following would be possible? list - /admin/customer/{customer_id}/addresses |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hey @ale1981, thanks for posting here. Can you please add some of your code here and point us to what you are trying to achieve? At this moment, it's not clear what exact issue you are facing. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi @phpfour Not sure code is going to help but I will try and explain a bit better. I have two models, a customer model and a customer address model. I have created a CustomerCrudController and a CustomerAddressCrudController. I only want the CustomerAddressCrudController to be accessed through a customer. What I want is to view a particular customers' addresses by visiting /admin/customer/{customer_id}/customer-addresses. I can list the relation on the CustomerCrud but when you have lots of results the relation column is no good. I hope that it's a little clearer?! |
Beta Was this translation helpful? Give feedback.
-
Nobody else had this problem with one to many relations? |
Beta Was this translation helpful? Give feedback.
-
Hi @pxpm Thanks, this has definitely put me in the right direction. I will let you know if it works as expected. Thanks |
Beta Was this translation helpful? Give feedback.
Hey @ale1981 sorry for the late reply.
It seems this issue fell through the cracks 👎
From your description, it seems you are trying to create a nested crud ?
If so, you have an example of that in our demo: https://github.com/Laravel-Backpack/demo/blob/main/app/Http/Controllers/Admin/PetShop/OwnerPetsCrudController.php
Let me know if that helps.
Cheers