title: Laravel dropdown gets all options even if not selected
body: <p>I have drop-down where i show my products attributes, and <strong>no matter if i select any option or not it will add all the options to my cart</strong> under selected product.</p>
  
  <p>what i need is to just get selected options or leave it empty if nothing has selected.</p>
  
  <p>here is my blade code:</p>
  
  <pre><code>&lt;tbody&gt;
    @foreach($options as $optiontitle =&gt; $optioncollection)
    &lt;tr&gt;
      &lt;td style="width: 150px;"&gt;{{ $optiontitle }}&lt;/td&gt;
      &lt;td class="text-left"&gt;
        &lt;select name="attr" class="form-control"&gt;
         &lt;option value=""&gt;Select&lt;/option&gt;
         @foreach($optioncollection as $suboption)
           &lt;option value="{{$suboption-&gt;id}}"&gt;{{$suboption-&gt;title}} - {{ number_format($suboption-&gt;price, 0) }}&lt;/option&gt;
         @endforeach
        &lt;/select&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    @endforeach
  &lt;/tbody&gt;
  </code></pre>
  
  <p>here is my controller method for <code>attributes</code> which i call them <code>option</code></p>
  
  <pre><code>$options = $product-&gt;suboptions-&gt;mapToGroups(function ($item, $key) {
    return [$item-&gt;option-&gt;title =&gt; $item];
  });
  </code></pre>
  
  <p>and this is my cart method where thing happen and everything will be add to cart instead of selected only.</p>
  
  <pre><code>public function addingItem(Request $request, $id)
      {
        $product = Product::where('id', $id)-&gt;firstOrFail();
  
        $customAttributes = [];
        if(!empty($product-&gt;suboptions)){
            foreach($product-&gt;suboptions as $subs) {
                array_push($customAttributes, [
                    'attr' =&gt; [
                        'label' =&gt; $subs-&gt;title,
                        'price' =&gt; $subs-&gt;price,
                    ]
                ]);
            }
        }
        Cart::add(array(
          'id' =&gt; $product-&gt;id,
          'name' =&gt; $product-&gt;title,
          'price' =&gt; $product-&gt;price,
          'quantity' =&gt; $request-&gt;input('quantity'),
          'attributes' =&gt; $customAttributes,
        ));
        Session::flash('success', 'This product added to your cart successfully.');
        return redirect()-&gt;back();
      }
  </code></pre>
  
  <h1>UPDATE</h1>
  
  <p>What I need to get is options <code>title</code> and <code>price</code> (take a look at my order sample to see why and where I need those)</p>
  
  <pre><code>"[{\"id\":29,\"name\":\"effewf\",\"price\":24524,\"quantity\":1,\"attributes\":[{\"attr\":{\"label\":\"Gray\",\"price\":\"7000.00\"}},{\"attr\":{\"label\":\"Red\",\"price\":\"5000.00\"}},{\"attr\":{\"label\":\"15\\\"\",\"price\":\"500000.00\"}},{\"attr\":{\"label\":\"17\\\"\",\"price\":\"700000.00\"}},{\"attr\":{\"label\":\"22\\\"\",\"price\":\"900000.00\"}}],\"conditions\":[]}]"
  </code></pre>
  
  <p>As you see in my <code>attributes</code> part I have nested array such as :</p>
  
  <pre><code>\"attributes\":[{\"attr\":{\"label\":\"Gray\",\"price\":\"7000.00\"}},....
  </code></pre>
  
  <p>here is where I get that <code>label</code> and <code>price</code> in my function loop.</p>
  
  <p>If I use loop such as:</p>
  
  <pre><code>foreach($request-&gt;attr as $subs) {
    array_push($customAttributes, [
     'attr' =&gt; [
      'label' =&gt; $subs-&gt;title,
      'price' =&gt; $subs-&gt;price,
      ]
  ]);
  </code></pre>
  
  <p>Instead of what I have I will get this error:</p>
  
  <blockquote>
    <p>Trying to get property of non-object</p>
  </blockquote>
  
  <p>on this line:</p>
  
  <pre><code>  'attr' =&gt; [
      'label' =&gt; $subs-&gt;title,
      'price' =&gt; $subs-&gt;price,
  </code></pre>
  
  <p>PS:
  If I use <code>$customAttributes = $request-&gt;attr;</code> with my own loop (at the top) I will get <code>id</code> of selected option only, which is no good to me.</p>