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

Pass Model Id to updateCRUD #151

Closed
b8ne opened this issue Oct 1, 2016 · 3 comments
Closed

Pass Model Id to updateCRUD #151

b8ne opened this issue Oct 1, 2016 · 3 comments

Comments

@b8ne
Copy link
Contributor

b8ne commented Oct 1, 2016

Heya, fairly sure this is a support request, because i know it will be simple, but I cant for the life of me find the answer.
Ive set up a custom nested controller, so the parent model is saved as normal, but through the display multiple children models also exist (can be created and updated).
Ive already handled this through the controller, the only thing I cant seem to find is the parent models id on update requests, obviously I need this to reference all of the child models off.
I will need to access the id not only on save/update, but also on render, so that I can fill the update view with existing data.
Any help would be appreciated.

@OwenMelbz
Copy link
Contributor

Not sure if this is any help, or i I've understood correctly, but these are just some ideas that maybe helpful to you

But when you submit the form, the request should contain id so you can access the items id via $request->input('id');as there is a hidden field on the form - Maybe you could use this?

If you have an instance of the parent model already, you could try using $model->getKey()

Additionally you could setup a method/relationship on the child models, which returns the parent? e.g if its stored in a column within the database?

@tabacitu
Copy link
Member

tabacitu commented Oct 2, 2016

Hmm... I'm not sure if I understand correctly. Telling us what you're trying to achieve (what columns and what fields) would help a lot.

I think your problem can be solved by having a "parent" field and column, just like it's done in the NewsCRUD documentation. Take a look at the Categories files - is this similar to what you need?

Cheers!

@b8ne
Copy link
Contributor Author

b8ne commented Oct 3, 2016

I just had a look at the NewsCRUD, I think its a little different.
Currently I have it working by doing a query in the field blade template based off of $id, but thought there would be a better way to do this outside of the templates with the other business logic.
I dont think refactoring will increase performance so theres no point trying to explain, I think ill just confuse everyone :)

@b8ne b8ne closed this as completed Oct 3, 2016
This was referenced Apr 2, 2020
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

3 participants