title: Laravel call to a member function addEagerConstraints() on boolean
body: <p>I'm getting the following error whenever i go on to a users page, its supposed to show if the authenticated user is already following the user that the profile is on.</p>
  
  <p>Could this be a problem with the relationship setup, it <code>hasMany</code></p>
  
  <p><strong>Stack trace</strong></p>
  
  <blockquote>
    <p>local.ERROR: Call to a member function addEagerConstraints() on
    boolean {"userId":1,"email":"fakeemail@aol.com","exception":"[object]
    (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0):
    Call to a member function addEagerConstraints() on boolean at
    /Applications/MAMP/htdocs/elipost/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:522)"}
    []</p>
  </blockquote>
  
  <p><strong>UserController.php</strong></p>
  
  <pre><code>public function getProfile($user)
  {  
      $users = User::with([
          'posts.likes' =&gt; function($query) {
              $query-&gt;whereNull('deleted_at');
              $query-&gt;where('user_id', auth()-&gt;user()-&gt;id);
          },
          'follow',
          'follow.follower'
      ])-&gt;with(['followers' =&gt; function($query) {
          $query-&gt;with('follow.followedByMe');
          $query-&gt;where('user_id', auth()-&gt;user()-&gt;id);
      }])-&gt;where('name','=', $user)-&gt;get();
  
      $user = $users-&gt;map(function(User $myuser){
          return ['followedByMe' =&gt; $myuser-&gt;followers-&gt;count() == 0];
      });
  
  
      if (!$user) {
          return redirect('404');
      }
  
      return view ('profile')-&gt;with('user', $user);
  }
  </code></pre>
  
  <p><strong>MyFollow(model)</strong></p>
  
  <pre><code>&lt;?php
  
  class MyFollow extends Model
  {
      use SoftDeletes, CanFollow, CanBeFollowed;
  
      protected $fillable = [
          'user_id',
          'followable_id'
      ];
  
      public $timestamps = false;
  
      protected $table = 'followables';
  
      public function follower()
      {
          return $this-&gt;belongsTo('App\User', 'followable_id');
      }
  
      public function followedByMe()
      {
        return $this-&gt;follower-&gt;getKey() === auth()-&gt;id();
      }
  
  
  }
  </code></pre>
  
  <p><strong>MyFollow</strong> </p>
  
  <pre><code>use Overtrue\LaravelFollow\Traits\CanFollow;
  use Overtrue\LaravelFollow\Traits\CanBeFollowed;
  
  class MyFollow extends Model
  {
      use SoftDeletes, CanFollow, CanBeFollowed;
  
      protected $fillable = [
          'user_id',
          'followable_id'
      ];
  
      public $timestamps = false;
  
      protected $table = 'followables';
  
      public function follower()
      {
          return $this-&gt;belongsTo('App\User', 'followable_id');
      }
  
      public function followedByMe()
      {
        return $this-&gt;follower-&gt;getKey() === auth()-&gt;id();
      }
  
  
  }
  </code></pre>
  
  <p><strong>Post</strong></p>
  
  <pre><code>class Post extends Authenticatable
  {
  
  
      protected $fillable = [
          'title',
          'body',
          'user_id',
          'created_at',
  
      ];
  
  
      public function user()
      {
          return $this-&gt;belongsTo(User::class);
      }
  
      public function comments()
      {
          return $this-&gt;hasMany('App\Comment');
      }
  
      public function likes()
      {
           return $this-&gt;hasMany('App\Like');
      }
  
      public function likedByMe()
      {
          foreach($this-&gt;likes as $like) {
              if ($like-&gt;user_id == auth()-&gt;id()){
                  return true;
              }
          }
          return false;
      }
  
  
  
  
  
  
  }
  </code></pre>
  
  <p><strong>Likes</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use App\Post;
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Database\Eloquent\SoftDeletes;
  
  class Like extends Model
  {
      use SoftDeletes;
  
       protected $fillable = [
          'user_id',
          'post_id'
      ];
  
  
  
  }
  </code></pre>
  
  <p><strong>User(model)</strong></p>
  
  <pre><code>class User extends Authenticatable
  {
      use Notifiable,CanFollow, CanBeFollowed;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'name', 'email', 'password',
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token',
      ];
  
  
      public function posts()
      {
          return $this-&gt;hasMany(Post::class);
  
      }
  
  
      public function images()
      {
          return $this-&gt;hasMany(GalleryImage::class, 'user_id');
  
      }
  
  
      public function likes()
      {
          return $this-&gt;hasMany('App\Like');
      }
  
      public function follow()
      {   
          return $this-&gt;hasMany('App\MyFollow');
      }
  
  
  
      public function comments()
      {
          return $this-&gt;hasMany('App\Comment');
      }
  
  
  
  
  }
  </code></pre>