ethar
1 month ago

send static data with eloquent result

Posted 1 month ago by ethar

from cookies, I get (item_id, item_qty), depend on item_id I make a select statement to return data,

I want to send item_qty with this statement to the blade

if(isset($_COOKIE["shopping_cart_panorama"])){
    $cookie_data = stripslashes($_COOKIE["shopping_cart_panorama"]);
    $cart_data=json_decode($cookie_data,true);
    $products=[];
    $qty=[];
    foreach ($cart_data as $key=>$values){
        array_push($products,$values['item_id']);
        array_push($qty,$values['item_qty']);//how send quantity with query result
    }
    $cart_product=Products::select('id','img', productName','price')
        ->whereIn('id',$products)
        ->where('active',1)
        ->get();
}
return view('front.cart',compact('cart_product'));

in the blade, I wat to show data get from the eloquent query, with the quantity of each product that comes from cookies

Please sign in or create an account to participate in this conversation.