D
D
Dmitry2018-09-12 21:39:20
Laravel
Dmitry, 2018-09-12 21:39:20

How to make query with WhereIn in laravel?

There is this code:

$services = "1,2";
$forms = Forms::whereIn('id',[$services])->get();

There are 2 entries in the database table that match the condition - under id = 1 and id = 2. But when I print out the forms collection, there is only one entry with id = 1.
Although if I write it manually , both entries are selected from the database. Help, what could be wrong? Requests are the same
$forms = Forms::whereIn('id',[1,2])->get();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-09-12
@liggth

$services = [1,2];
$forms = Forms::whereIn('id', $services)->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question