Skip to content

PHP code snippet – How to insert multiple data at a time with create method in laravel?

$data = [
    ['user_id'=>'Coder 1', 'subject_id'=> 4096],
    ['user_id'=>'Coder 2', 'subject_id'=> 2048],

Model::insert($data); // Eloquent approach
DB::table('table')->insert($data); // Query Builder approach
See also  How to create an array in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.