title: Get count of unique values with the column name in Laravel 5.2 Collection
body: <p>I am trying to get the number of unique Brands from my Products Table with their count from a Laravel collection. </p>
  
  <p>I was able to do that using a specific query for the products but the reason i'm using a collection now is because i also want to get the Product Origins (Country), Conditions (Used / New) of the products and i thought it would be much better to use a collection from one query rather than have three separate queries for each data. </p>
  
  <p>The code below works but it doesn't show the count for each unique Brand.</p>
  
  <p>Here is the Table
  <a href="https://i.stack.imgur.com/NcYTG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NcYTG.jpg" alt="enter image description here"></a></p>
  
  <p>Here is my Controller</p>
  
  <pre><code>$products = DB::table('products')
   -&gt;select('products.*')
   -&gt;whereNull('products.deleted_at')
   -&gt;get();
  
  $BrandCollection = collect($products);
  $Brands = $BrandCollection-&gt;unique('Brand')-&gt;sortBy('Brand')-&gt;keyBy('Brand')-&gt;pluck('Brand');
  </code></pre>
  
  <p><strong>So, the result i'm looking for is</strong> </p>
  
  <p>HP 3<br/>
  Toshiba 2<br/>
  Lenovo 1</p>
  
  <p>I thought it could be done using concat for the collection but since i'm on Laravel 5.2, i'm looking for other solutions.</p>