3 Answers 3

1

The only way to insert multiple rows at once is using Model::insert($data). To use this method, you should prepare data first. Here's correct data structure for insert() method:

$data = [
    ['name' => 'John', 'age' => 32],
    ['name' => 'Steve', 'age' => 25],
    ['name' => 'Mari', 'age' => 20],
];
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

$insert = array(
    0 => array(
        'col1' => 'val1',
        'col2' => 'val2',
    )
    1 => array(
        'col1' => 'val1',
        'col2' => 'val2',
    )
);

DB::table('tablename')->insert($insert);

Comments

0

You may use 'name' tag for the inputs then request them in the store method of the controller like this:

$request->name_of_the_inputs 

this will return to you a collection, so you should exploit the data through a for loop

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.