title: Laravel Undefined Method
body: <p>I am getting the following error on my query when the interest method exists in my model. </p>
  
  <blockquote>
    <p>Call to undefined method Illuminate\Database\Query\Builder::interest()</p>
  </blockquote>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>public function index() {
      $user_id = auth()-&gt;user()-&gt;id;
      $user = User::find($user_id);
  
      $interests = Space::where('user_id', $user_id)-&gt;interest()-&gt;get();
  
      return view('dashboard')-&gt;with('space', $user-&gt;space)-&gt;with('interest', $interests-&gt;space);
  }
  </code></pre>
  
  <p><strong>Space Model:</strong> </p>
  
  <pre><code>public function user(){
      return $this-&gt;belongsTo(User::class);
  }
  
  public function interest(){
      return $this-&gt;hasMany(Interest::class);
  }
  </code></pre>
  
  <p><strong>Interest Model:</strong></p>
  
  <pre><code>public function user(){
      return $this-&gt;belongsTo(User::class);
  }
  
  public function interest(){
      return $this-&gt;belongsTo(Space::class);
  }
  </code></pre>