Where in eloquent orms

I have two arrays



now for example if I have data in my array, something like this

    temp   time 
[0]  80     45
[1]  70     50
[2]  85     65
[3]  90     30 


I want to query data in terms of these two array parameters (select * from MyTable where (temperature = 80 and time = 45)) for next (select * from MyTable where (temperature = 70 and time = 50)), etc. ...

I am doing something like this

 $mix=MyTable::whereIN('temperature', $temp)
         ->whereIN('time', $time)->where('category',$cat)


But the output it produces is a combination of the two. Not from array 0 to and on ...

Hope I explained my question correctly.

I tried this.

    $result=Ergebnisse::where('name_id', $nam)->where('geometrie_id', $geo)->get();
    foreach ($result as $key => $res) {

$mix=Ergebnisse::where('temperatur', $res->temperatur)
         ->where('zeit', $res->zeit)->groupBy('katogorie_id')



when i dd ($ mix) only shows one result. but according to my db it should show more than one


source to share

1 answer


won't work here. Do something like this:

$data = MyTable::where('category', $cat)
    ->where(function($q) use($array) {               
        foreach ($array as $item) {
             $q->orWhere(function($q) use($item) {
                 $q->where('temperature', $item['temp'])
                   ->where('time', $item['time']);




All Articles