我想从 table salles 指定 code_sale 我有一个值数组但它只 returns 根据数组中的第一个值

I want to specify code_sale from table salles where I have an array of values ​but it only returns according to the first value in the array

    $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"}]

可能是我语法有误

您想尝试 whereInhttps://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;