Hi Guys,
I have the following query
DB::table('product_sales')
->join('product_views', 'product_sales.session', '=','product_views.session')
->select('product_views.reference_id AS prod_view_id',
'product_sales.reference_id AS prod_bought_id',
'product_sales.session')
->take($num)
->get();
returning a json collection like the one bellow
[
{
"prod_view_id": 202901,
"prod_bought_id": 226122,
"session":34343"
},
{
"prod_view_id": 202901,
"prod_bought_id": 146606,
"session": "4566"
}
]
and I'm trying to save it into another table
foreach ($items as $item) {
XTimesSessionBoughtProduct::insert($item);
}
but I'm getting the following error message "must be of the type array, object given" which I understand, but I'm wondering how to return an array and not json object or is it another way I can do this ? Thank you for you time.