fightstarr20
fightstarr20

Reputation: 12588

Laravel 5.5 - whereIn array

In Laravel 5.5, I am trying to get all fruits that have a fruit_id from an array like this..

$fruits = Fruit::whereIn('fruit_id',[6,23,5,73]);

This is not returning any results, am I doing this correctly or is there a better way of doing things?

Upvotes: 1

Views: 348

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163758

You forgot to execute the query. Add ->get():

$fruits = Fruit::whereIn('fruit_id',[6,23,5,73])->get();

Upvotes: 4

Related Questions