Submitting multiple rows with a single form entry.
Hi,
I am just a week old to Laravel. I have a page passing multiple group of elements to the same method in my controller. More explanation: Say you want to do a bulk submission into a database table using a single form entry. I know the "input::all()" grabs all the data elements, but since you can't tell the specifics at run time, is there any way of handling that?
You have to structure the names of your fields in your html. Example : 'entities[index][name]' with index being the same value for all the fields of the same entity. So in your controller action you get an array of values ['entities' => [0 => ['name' => 'name of entity 1'], 1 => ['name' => 'name of entity 2'], ...]].
Then you can loop through your entities in your controller action :
foreach ($request->entities as $entity) {
Entity::create($entity);
}