title: How can I make a collection unique?
body: <p>Here is my code:</p>
  
  <pre><code>$products = Products::orderBy('id')-&gt;get();
  </code></pre>
  
  <p>And here is my table:</p>
  
  <pre><code>// products
  +----+----------+----------+
  | id |  brand   |   name   |
  +----+----------+----------+
  | 1  | Cisco    | SF300-48 |
  | 2  | Mikrotik | RB260GS  |
  | 3  | Mikrotik | PoEhEX   |
  +----+----------+----------+
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>foreach($products as $product){
      echo $product-&gt;brand.PHP_EOL;
  }
  </code></pre>
  
  <p><strong>Current result:</strong></p>
  
  <pre><code>/* Cisco
     Mikrotik 
     Mikrotik 
  </code></pre>
  
  <p><strong>The expected result:</strong></p>
  
  <pre><code>/* Cisco
     Mikrotik 
  </code></pre>
  
  <p>See? I need to make a laravel collection unique. <code>array_unique()</code> is for arrays and I cannot use it here. Any idea how can I do that?</p>
  
  <p>Noted that I need to all names. <em>(I mean I need these values <code>SF300-48</code>, <code>RB260GS</code>, <code>PoEhEX</code>)</em>. So I cannot use <code>DISTINCT</code> in the query either.</p>