I wanna use a form partial for a new and for an existing object.
I found similar questions:
but I can't and don't wanna save the parent object.
I came from the rails view with active record. I can do the following:
Let's say I have a category which includes many products:
category = Category.new
category.products << Product.new
Now I can iterate through the products like
category.products.each do ...
Now I want the same in laravel with an eloquent model
$category = new Category();
$category->products()->....
add
does not exist for the Builder.
save
needs a stored category
attach
needs the same
is there a way to get my idea working? My goal is to use the same form partial for edit and creating a model with defined relations.