I am trying to fetch multiple rows of selected IDs from db. Here is my controller code
$products = new product;
$products = $products->select('products.*', 'categories.category_name')->join('categories', 'products.product_category', '=', 'categories.id');
$products = $products->whereIn('products.id', [$request->list]); //$request->list is post value (12,13)
$products = $products->get();
Here $request->list is post value which contains 12,13. Mentioned code works fine if I manually type IDs like this.
$products = $products->whereIn('products.id', [12,13]);
But if I try to call same with variable or directly with request post then it is returning only one result.
$products = $products->whereIn('products.id', [$request->list]);
//OR
$id = $request->list;
$products = $products->whereIn('products.id', $id);
Why it is giving only one result when I use variable, any idea?