title: Change value in session and save it. Laravel
body: <p>I want to update product price when I submit coupon code I named my coupon as <code>ticket</code>. This is my function: </p>
  
  <pre><code>public function order(Request $request)
      {
          $products = session('cart');
  
          $ticket_code = Input::get('ticket');
          $ticket = Ticket::where('ticket', $ticket_code)-&gt;first();
  
          foreach($products as $p){
              $price = $p['price'];
          }
  
          if(count($products) &amp;&amp; $ticket['max'] &gt; $ticket['used']) {
              $subtotal = [$price*70/100];
              $ticket-&gt;used += 1;
              $ticket-&gt;save();
              foreach($products as $p){
                  $p['price'] = $subtotal;
                  $p-&gt;save();
              }
              flash()-&gt;success('Kuponas sėkmingai panaudotas!');
              return view('cart.order')-&gt;with(array(
                  'products' =&gt; $products,
                  'subtotal' =&gt; $subtotal,
              ));
  
          }
  
          else {
              $finalTotal = 0;
              $subtotal = [];
              return view('cart.order')-&gt;with(array(
                  'products' =&gt; $products,
                  'subtotal' =&gt; $subtotal,
                  'finalTotal' =&gt; $finalTotal
              ));
          }
  
  
      }
  </code></pre>
  
  <p>this code doesnt work: </p>
  
  <pre><code>  foreach($products as $p){
                  $p['price'] = $subtotal;
                  $p-&gt;save();
              }
  </code></pre>
  
  <p>I get error: <code>Call to a member function save() on array</code></p>
  
  <p>Without the <code>foreach</code> the <code>ticket</code> itselfs works. It changes the price when submited, but only in that one page. Then when I go to payment site, the price is still displayed without <code>ticket</code> used. </p>
  
  <p><strong>THE WORKING SOLUTION</strong></p>
  
  <pre><code>    foreach($products as &amp;$item) {
                      $item['price'] = $item['price']*70;
                      $item['price'] = $item['price'] / 100;
                  }
  
  Session::put('cart', $products);
  </code></pre>