In my project I have a dynamic form of the following structure:
- Date 1
- Shift 1
- Area 1
- Cell 1
- Cell 2
- Area 2
- Cell 3
- Cell 4
- Shift 2
- Area 1
- Cell 1
...
I take data from inputs with the following multidimensional array: data[index][column], where a column may be: date, shift, area, cell, or cell content.
Then I need to store this form into database to be able to recreate it later. It's easy, because my array has a table form:
index | Date | Shift | Area | Cell | Cell Content
1 05.06 1 1 1 100
2 05.06 1 1 2 99
3 05.06 1 2 3 55
4 05.06 1 2 4 66
5 05.06 2 1 1 35
But when to recreate the form (take it back from the database), it would be better to convert this array into a collection, to be able to do the following foreach:
foreach (dates as date)
foreach (date->shifts as shift)
foreach (shift->areas as area)
foreach (area->cells as cell)
echo cell->content
endforeach
endforeach
endforeach
endforeach
Is it possible in Laravel? Or I need to use the old method: comparison current element with precedent and break the for when different?