You can bulk insert to database table using either Eloquent or query builder in Laravel.
$data = array( array('post_id'=>'1', 'image_id'=> 20), array('post_id'=>'2', 'image_id'=> 22), //.... );
Eloquent way
Model::insert($data);
Query builder way.
DB::table('yourtable')->insert($data);
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.