title: Call to a member function addEagerConstraints() on float LARAVEL
body: <p>My objective is to get average review of the courses available. But when i am trying to get the average review of the course its throwing me an error saying <code>"message": "Call to a member function addEagerConstraints() on float"</code></p>
  
  <p>My Course Model</p>
  
  <pre><code> public function rating(){
      return $this-&gt;hasMany(Rating::class);
  }
  public function averageRating(){
      return round($this-&gt;rating()-&gt;avg('ratings'),1);
  }
  </code></pre>
  
  <p>Rating model</p>
  
  <pre><code> public function user(){
          return $this-&gt;belongsTo(User::class);
      }
      public function course(){
          return $this-&gt;belongsTo(Course::class);
      }
  </code></pre>
  
  <p>My Controller</p>
  
  <pre><code>$result = Course::with('averageRating')-&gt;get();
  </code></pre>
  
  <p>I was expecting it to give Course detail along with average rating of each course but it throwing error.
  Can anyone please help me?? 
  Thank you</p>