There is the following code

$relations = PR::where('status','1') ->whereIn('id',array($PR['related'])) ->get(); 

The fact is that the query returns only 1 element, if you insert such a query, it will output all 3 elements

 $relations = PR::where('status','1') ->whereIn('id',array(1,2,3)) ->get(); 

Why is this happening? considering that $ PR ['related'] is 1,2,3

    1 answer 1

     ->whereIn('id',explode(',', $PR['related'])) 

    array($PR['related']) is array('1,2,3') , which, you see, is not the same as array(1, 2, 3) .