У меня есть код:
$filter = \DB::table('attribute_products') ->select('attr_id') ->where('product_id', $id) ->get() ->toArray();
Это дает мне массив вроде:
Однако я хочу вот так:
Вы хотите использовать метод срыва (https://laravel.com/docs/master/queries#retrieving-results)
$filter = \DB::table('attribute_products') ->where('product_id', $id) ->pluck('attr_id');
Не нужно вводить ->toarray();, просто используйте:
->toarray();
$filter = \DB::table('attribute_products') ->select('attr_id') ->where('product_id', $id) ->get() ;