Skip to content
Advertisement

Laravel WhereIn array returns only first index results

JavaScript

returns only data for “9” but when i trying like this:

JavaScript

how can i fix it?

Advertisement

Answer

As I see, this line $dean_ids = Auth::user()->dean_id; returns a comma-separated string. So when you make $dean_ids array by using [$dean_ids] it actually makes an array like:

JavaScript

Instead of

JavaScript

There is only one value inside the array. So what you can do just use explode for splitting the string by using a comma and it also returns an array.

You can try this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement