title: Generating A drop down Grouped List laravel
body: <p>I am trying to create a drop down list with products divided by categories, so I can't just use a list like usually I do when I have to list element in a drop down. What I did:</p>
  
  <pre><code>$products= DB::table('prod')                
      -&gt;join('cat','cat.id','=','prod.id_cat')
      -&gt;join('campo_cat','campo_cat.id_cat','=','cat.id')
      -&gt;join('campo','campo.id','=','campo_cat.id_campo')
      -&gt;join('cat_nome','cat_nome.id_cat','=','cat.id')
      -&gt;join('lingua','cat_nome.id_lingua','=','lingua.id')
      -&gt;where('lingua.lingua','=','it-IT')        
      -&gt;groupBy('prod.nome')
      -&gt;select('prod.nome as nameprod','cat_nome.nome as namecat','prod.id as id')-&gt;get();
  
  $category = [];
  foreach ($products as $product) 
  {
      if (!isset($category[$product-&gt;namecat])) 
      {
          $category[$product-&gt;namecat] = [];
      }
      array_push($category[$product-&gt;namecat], $product-&gt;nameprod);           
  }
  </code></pre>
  
  <p>Then I pass it to my view:</p>
  
  <pre><code>{{ Form::select('category', array($categorie)) }}
  </code></pre>
  
  <p>Now I can see a drop down, divided by category of my product name, but my key value of array is not the id but it's the standard <code>0=&gt; 1=&gt;</code> etc. I want that the values of my drop down select corresponds to the product id. I tried <code>array_combine()</code> an array of id with <code>array_values()</code> of my array, but it gives error because the name of the category that group each products have <code>null</code> values, then it return me array to string conversion error.</p>