title: Best practice for making a custom query in a model
body: <p>I have a model named "Rate" and a related controller named "RateController".
  if want to make a custom query in Rate model, we could use local scope or static function like these:</p>
  
  <p>using static function in the Rate model:</p>
  
  <pre><code>public static function avgerage($type, $id)
  {
      return static::where('rateble_type', $type)
                  -&gt;where('rateble_id', $id)
                  -&gt;avg('star');
  }
  </code></pre>
  
  <p>using local scope in Rate model:</p>
  
  <pre><code>public function scopeAverageRate($type, $id, $query)
  {
      return $query-&gt;where('rateble_type', $type)
                   -&gt;where('rateble_id', $id)
                   -&gt;avg('star');
  }
  </code></pre>
  
  <p>and finally, we call one of the above methods in the controller.</p>
  
  <p>The question is, which one is the best practice?
  using a local scope or defining a static function in the model?</p>
  
  <p>Thank you.</p>