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

171
Views
generador de consultas laravel para agregar o condicionar

Recibir la solicitud en formato de matriz

 [ [ [ 'condition1', 'value1', ], [ 'condition2', 'value2', ], ], [ 'condition3', 'value4', ] ]

Estoy tratando de crear un generador de consultas con valores 1 y valores 2 en la condición 'o' y valor 3 en la condición 'y'

$resultado = DB::tabla('tabla')

 foreach($values as $value){ // $result->where(function ($qry) use ($value) { // array 0,1 with and condition foreach($value as $val){ // values1 , values2 $qry->where(); } }); }

Cómo agregar la condición 'o' entre los valores 1 y los valores 2 y luego la condición 'y' con el valor 3.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No necesita ningún bucle, necesita una subconsulta , como esta:

 $result = DB::table('table') ->where(function($query) use($value1) { $query->where('condition1', $value1) ->orWhere('condition2', $value1); }) ->where('condition3', $value2) ->get();
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!