lundi 4 novembre 2019

is there any way to store the radio button value in session in laravel

I am working on shopping cart where user can select size of product but when i click submit it just submit the last id not getting the id of selected radio button

please see my code controller

public function getAddToCartsuboption(Request $request,$id){
        $menu = SubMenu::find($id);
       // dd($menu);
        $oldCart = Session::has('cart') ?  Session::get('cart'):null;
        $cart = new Cart($oldCart);
        $cart ->add($menu, $menu ->id);
        $cart  = $request->session()->put('cart', $cart);
        $query  = DB::select('SELECT * FROM  pizza_options');
        //$option = DB::select('SELECT type from pizza_options');
        return view('pizzatypes',compact('query')); 

       // return $this->getCart();
    // dd($cart['85']->menu_name);

// 
// dd($arraytest['items'][85]['item']['menu_name']);



        ///dd($request->session()->get('cart'));
        //return view('main'); 
    }

this is view

<div class="products card__body grid"> 
  <meta itemprop="description" content=""> 
   @foreach($query as $index => $parcel) 
   <div class="media media--photo media--photo--compact grid__cell--1/2 grid__cell--1/3@desktop" itemprop="hasMenuItem" itemtype="http://schema.org/MenuItem" itemscope=""> <meta itemprop="description" content="Coca Cola 1,5 L - 0,45 L - 0,33 L"> <div class="media__image productImage">  </div>
   <div class="radio" id ="optradio">
    <label><input type="radio" value="" class="optradio" id="optradio" name="optradio[]"> - From <b>CHF </b></label>
</div>
</div> 

@endforeach

     </div> 

   </section></div>
<div class="grid grid--no-gutter"> <div class="grid__cell--1@desktop"> <a class="btn media__btn is-hidden@handheld" href="" data-dpz-track-evt-name="Order | COCA COLA"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Order</font></font></a>
   </div> </div>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire