I
I
Ilya Parshakov2018-05-06 23:46:28
Laravel
Ilya Parshakov, 2018-05-06 23:46:28

How to save array from request to eloquient?

Hello! I get data from the form in request, which needs to be saved in 3 different database tables (3 different models). In one of the tables, you need to save the data of the form in bulk:

"title" => array:2 [▼
  1 => "<p>1 Название<br></p>"
  2 => "<p>2 Название<br></p>"
]
"data" => array:2 [▼
  1 => array:3 [▼
    1 => "data 1"
    2 => "data 2"
    3 => "data 3"
  ]
  2 => array:4 [▼
    1 => "data 1"
    2 => "data 2"
    3 => "data 3"
    4 => "data 4"
  ]
]
"rate" => array:2 [▼
  1 => array:3 [▼
    1 => "1"
    2 => "2"
    3 => "3"
  ]
  2 => array:4 [▼
    1 => "4"
    2 => "5"
    3 => "6"
    4 => "7"
  ]
]

Can this be done using eloquient to create and update this data?
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question