title: Retrieve the minimum in Laravel relationship
body: <p>I working on App similar to CRM App(Customer Relation Management)</p>
  
  <p>I have the following code that get array of <code>$ms</code> that assigned to user </p>
  
  <pre><code>   //check if contract end or not and active or inactive
    // and first_date_for_service &lt; now()
      $ms= MaintenanceService::join('cus_contract','cus_contract.id','=','maintenance_service.contract_id')
          -&gt;where('cus_contract.status','=','active')
          -&gt;where('cus_contract.contract_end_at','&gt;',Carbon::now())
          -&gt;where('maintenance_service.user_id', Auth::user()-&gt;id)
          -&gt;where('maintenance_service.first_date_for_service','&lt;', Carbon::now())
          -&gt;get();
  </code></pre>
  
  <p>now i have array of <code>$ms</code> so i will loop over it as following</p>
  
  <pre><code>  for($x = 0; $x&lt; count($ms);$x++) {
     // here i get all notifications for $ms[$x] in each loop using Eloquent
        return count($ms[$x]-&gt;notifications);
      }
  </code></pre>
  
  <p>The above code working well,but i need fetch the minimum firstly ,for example </p>
  
  <p>in first loop the count of notifications <strong>3</strong>
  and in the second count was <strong>2</strong>.</p>
  
  <p><strong>but i need the min in first</strong> so when <code>return $ms[$x]-&gt;notifications;</code> 
  i need return the array that carries the min count in our case <strong>2</strong></p>
  
  <p><strong>Is there any way to achieve that ?</strong></p>
  
  <p>Thanks for your time.</p>