Home > other >  I want to specify code_sale from table salles where I have an array of values ​but it only returns a
I want to specify code_sale from table salles where I have an array of values ​but it only returns a

Time:05-20

    $array1=['A1','A2','A3','A4'];
    $test=salle::select('code_salle','type_salle')->where('code_salle',$array1)->get();
     return $test;

return

[{"code_salle":"A1","type_salle":"AMPHI"}]

Maybe I'm wrong in the syntax

CodePudding user response:

You want to try whereIn instead: https://laravel.com/docs/9.x/queries#additional-where-clauses

$array1=['A1','A2','A3','A4'];
$test=salle::select('code_salle','type_salle')->whereIn('code_salle',$array1)->get();
return $test;
  • Related