title: Issue with Generating Random Numbers using Laravel contains vs foreach loop
body: <p>Hey guys I come across this strange issue where if I use the foreach it does not generate a unique random number wheres if I use laravel function contains. it always generate a random number</p>
  <p>I'm curious how this can happen</p>
  <p>see my code below</p>
  <pre><code>          #Main Function subscribers are an eloquent collection 
            
           foreach ($this-&gt;subscribers as $subscriber){
              $subscriber-&gt;drawOrder = $this-&gt;generateRandomNumbers();
           }
  
           dd($this-&gt;subscribers-&gt;pluck('drawOrder'));
  
      }
  
  
      public function generateRandomNumbers()
      {
  
          $number = mt_rand(1, count($this-&gt;subscribers));
  
          if ($this-&gt;checkIfUserHasDraw($number)) {
              return $this-&gt;generateRandomNumbers();
          }
  
          return $number;
      }
  
      public function checkIfUserHasDraw($number)
      {
  
        //return $this-&gt;subscribers-&gt;contains('drawOrder', $number);
  
          foreach ($this-&gt;subscribers as $user) {
              return $user-&gt;drawOrder == $number;
          }
      }
  </code></pre>
  <p>Output</p>
  <pre><code>0 =&gt; 3
  1 =&gt; 5
  2 =&gt; 1
  3 =&gt; 5
  4 =&gt; 1
  </code></pre>
  <p>Where's if I use the commented contains method it comes with unique random values</p>
  <p>This is strange. Any thoughts on this is really helpful</p>