upgrading to laravel 5.3, "Call to undefined method Illuminate\Database\Query\Builder" error
<p>I have a  Laravel 5.2 project that works great. I tried to upgrade it to Laravel 5.3 and it gave errors such as:</p>

<blockquote>
  <p>BadMethodCallException in Builder.php line 2448: Call to undefined method Illuminate\Database\Query\Builder::friends()</p>
</blockquote>

<p>or any other methods in my <code>User.php</code> model have the same error.
For example, when I comment <code>friends()</code> in <code>HomeController.php</code> I have:</p>

<blockquote>
  <p>BadMethodCallException in Builder.php line 2448: Call to undefined method Illuminate\Database\Query\Builder::getNameOrUsername()</p>
</blockquote>

<p>This is my <code>User</code> model:</p>

<pre><code>&lt;?php

namespace Activentum\Models;

use Activentum\Models\Status;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract ;

class User extends Model implements AuthenticatableContract
{
    use Authenticatable;

    protected $table = 'users';

    protected $fillable = [
        'username',
        'email', 
        'password',
        'first_name',
        'last_name',
        'location',


    ];

    protected $hidden = [
        'password',
        'remember_token',
    ];


    public  function getName()
    {
        if ($this-&gt;first_name &amp;&amp; $this-&gt;last_name){
            return "{$this-&gt;first_name} {$this-&gt;last_name}";
        }

        if ($this-&gt;first_name) {
            return $this-&gt;first_name;
        }
        return null;
    }


    public function getNameOrUsername()
    {
        return $this-&gt;getName() ?:$this-&gt;username;
    }    
    public function getFirstnameOrUsername()
    {
        return $this-&gt;first_name ?: $this-&gt;username;
    }
    public function getAvatarUrl()
    {
        return "https://www.gravatar.com/avatar/
        {{md5($this-&gt;email)}}?d=mm&amp;s=40";
    }



    public function statuses()
    {
        return $this-&gt;hasMany('Activentum\Models\Status', 'user_id');
    }
    public function likes()
    {
        return $this-&gt;hasMany('Activentum\Models\Like', 'user_id');
    }
    public function friendsOfMine()
    {
        return $this-&gt;belongsToMany('Activentum\Models\User',
         'friends', 'user_id','friend_id');    
    }

    public function friendOf()
    {
        return $this-&gt;belongsToMany('Activentum\Models\User',
         'friends', 'friend_id', 'user_id');    

    }

    public function friends()
    {
        return $this-&gt;friendsOfMine()-&gt;wherePivot('accepted', true)-&gt;get()-&gt;
            merge($this-&gt;friendOf()-&gt;wherePivot('accepted', true)-&gt;get());
    }

    public function friendRequests()
    {
        return $this-&gt;friendsOfMine()-&gt;wherePivot('accepted', false)-&gt;get();
    }    


    public function friendRequestsPending()
    {
        return $this-&gt;friendOf()-&gt;wherePivot('accepted', false)-&gt;get();
    }

    public function hasFriendRequestsPending(User  $user)
    {
        return (bool) $this-&gt;friendRequestsPending()-&gt;
        where('id', $user-&gt;id)-&gt;count();

    }

    public function hasFriendRequestsReceived(User  $user)
    {
        return (bool) $this-&gt;friendRequests()-&gt;where('id', $user-&gt;id)-&gt;count();
    }

    public function addFriend(User  $user)
    {
      $this-&gt;friendOf()-&gt;attach($user-&gt;id);
    }

    public function deleteFriend(User $user)
    {
        $this-&gt;friendOf()-&gt;detach($user-&gt;id);
        $this-&gt;friendsOfMine()-&gt;detach($user-&gt;id);  
    }

    public function acceptFriendRequest(User  $user)
    {
        $this-&gt;friendRequests()-&gt;where('id', $user-&gt;id)-&gt;first()
        -&gt;pivot-&gt;update(['accepted'=&gt; true, ]);
    }

    public function isFriendWith(User $user)
    {
        return (bool) $this-&gt;friends()-&gt;where('id', $user-&gt;id)-&gt;count();
    }
    public function hasLikedStatus(Status $status)
    {
        return (bool) $status-&gt;likes
        -&gt;where('user_id', $this-&gt;id)-&gt;count();

    }
}
</code></pre>

<p>And my <code>HomeController</code>:</p>

<pre><code>&lt;?php
    namespace Activentum\Http\Controllers;

    use Auth;
    use Activentum\Models\Status;

    class HomeController extends  Controller 
     {

    public function index()
    {
        if (Auth::check()) {
            $statuses = Status::notReply()-&gt;where(function($query){
                return $query-&gt;where ('user_id', Auth::user()-&gt;id)
                -&gt;orWhereIn('user_id',Auth::user()-&gt;friends()-&gt;pluck('id')
                    );
            })
            -&gt;orderBy('created_at','desc')-&gt;
            paginate(14);

            return view ('timeline.index')
                -&gt;with('statuses', $statuses);
        }

        return view('home');
    }

}
</code></pre>

<p>It seems that project can't see the model. My models are in the Models folder in <code>app/Models</code>.</p>