F
F
frontendo2017-01-04 21:12:27
Laravel
frontendo, 2017-01-04 21:12:27

How to create multiple rows in one table with one query?

ProductAttribute::create(['name' => 'Width', 'units' => 'cm', 'type_id' => '3']);
ProductAttribute::create(['name' => 'Height', 'units' => 'cm', 'type_id' => '3']);
ProductAttribute::create(['name' => 'Thickness', 'units' => 'cm', 'type_id' => '3']);
ProductAttribute::create(['name' => 'Weight', 'units' => 'kg', 'type_id' => '3']);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-01-04
@frontendo

www.stackoverflow.com/a/29723968/1603055

S
Sergey, 2017-01-04
@gangstarcj

Write a createAll method and pass values ​​​​into it as an array, and from it pass via a forward to the create method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question