vendredi 3 juillet 2020

Access the cart session - Laravel 5.8

Hi i am using sopping cart in laravel 5.8. I want to access the array to be able to store the order in the database. I was able to access the data in the session cart. But to the part of options -> marca y medida. Also I do not know how to bring the total cart.

My controller is as follows

public function transferencia(Request $request)
    {
        $cart = Session::get('cart');
  
            foreach ($cart as $key => $order) {
                $data = json_decode($order, true); 
                foreach($data as $item){
                    $opt = new Order;
                    $opt->id_cliente = $request->input('idusuario');
                    $opt->fecha = date('j/n/Y');
                    $opt->cliente = $request->input('persona');
                    $opt->dni = $request->input('dni');
                    $opt->producto = $item['name'];
                    $opt->medida = 'medida'; //how to access this data
                    $opt->marca = $item['marca']; //how to access this data
                    $opt->precio = $item['price'];
                    $opt->cantidad = $item['qty'];
                    $opt->total = 'total'; //how to access this data
                    $opt->factura = 'factura';
                    $opt->idpedido = 'idpedido';
                    
                    $opt->save();
                } 
                
            }
            //dd($item);   
            //print_r($cont);     
    }

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire