Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
Laravel DB Query insertar lista de ids

Cómo puedo insertar una lista de ID con una consulta DB sin usar foreach.

ejemplo con foreach:

 $ids=[1,3,5]; foreach ($ids as $id) { DB::Table('user')->insert(['name'=>'test','user_id'=>$id]); }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar array_map ;

 $ids = [1, 3, 5]; $data = array_map(function ($id) { return ['name' => 'test', 'id' => $id]; }, $ids); DB::table('user')->insert($data);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!