title: Laravel select groupby only not nullable values
body: <p>I have a model Products. In the table there are columns id,description,barcode,sizebarcode,price. Sizebarcode column has some values and also nullable values. I want to grouping sizebarcode column where are not nullable values. Null values are directly selected without grouping. I want to omit nullable values when grouping.</p>
  
  <p>I want to select all unique values in sizebarcode and also with all nullable values</p>
  
  <p>Controller.php</p>
  
  <pre><code>$products = Category::where('slug',$slug)-&gt;first()-&gt;products_front()-&gt;paginate(12);
  
  return view('page.shop',compact('products'))
  </code></pre>
  
  <p>Model.php</p>
  
  <pre><code> public function products_front(){
  return $this-&gt;hasMany('App\Product','cat_id','id')
      -&gt;groupBy('sizebarcode')
      -&gt;orderBy('created_at','asc');
  </code></pre>
  
  <p>}</p>
  
  <p><a href="https://i.stack.imgur.com/u1ce7.png" rel="nofollow noreferrer">My table</a></p>
  
  <p><a href="https://i.stack.imgur.com/2dpPA.png" rel="nofollow noreferrer">What are I want</a></p>