Laravel pass value to model
<p>Right now I try this query with eloquent:</p>

<pre><code>'MentorId'  =&gt; $employee-&gt;intern(true)-&gt;mentor(true)-&gt;MentorId,
</code></pre>

<p>And in my <code>employee</code> and <code>intern</code> model I've got this:</p>

<p><strong>Intern</strong></p>

<pre><code>  /**
     * @return mixed
     */
    public function intern($withTrashed = false)
    {
        if($withTrashed == true)
        {
            return $this-&gt;belongsTo(internModel::class, 'InternId')-&gt;withTrashed();
        }

        return $this-&gt;belongsTo(internModel::class,'InternId');
    }
</code></pre>

<p><strong>Mentor</strong></p>

<pre><code> /**
     * @return mixed
     */
    public function mentor($withTrashed = false)
    {
        if($withTrashed == true)
        {
            return $this-&gt;belongsTo(mentorModel::class, 'MentorId')-&gt;withTrashed();
        }

        return $this-&gt;belongsTo(mentorModel::class,'MentorId');
    }
</code></pre>

<p>But it crashes:</p>

<pre><code>BadMethodCallException in Builder.php line 2148:
Call to undefined method Illuminate\Database\Query\Builder::mentor()
</code></pre>

<p>How could I fix this?</p>

<p>--EDIT--</p>

<p><strong>Employee</strong></p>

<pre><code>&lt;?php

namespace App\src\employee;

use Illuminate\Foundation\Auth\User as Authenticatable;
use App\src\department\Department as departmentModel;
use App\src\employee\Employee as employeeModel;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\src\intern\Intern as internModel;
use App\src\mentor\Mentor as mentorModel;
use App\src\employee\Role as roleModel;

class Employee extends Authenticatable
{
    use SoftDeletes;
    use EmployeeServiceTrait;

    /**
     * table name
     */
    protected $table = 'employee';

    /**
     * Mass assignment fields
     */
    protected $fillable = ['RoleId', 'DepartmentId', 'InternId', 'FirstName', 'LastName', 'Bio','api_token', 'email', 'LinkedIn', 'password', 'Address', 'Zip', 'City', 'ProfilePicture', 'BirthDate', 'StartDate', 'EndDate', 'Suspended','LinkedIn'];

    /**
     * Primarykey
     */
    protected $primaryKey = 'EmployeeId';

    /**
     * Deleted_at
     */
    protected $dates = ['deleted_at'];

    /**
     * @return mixed
     */
    public function role()
    {
        return $this-&gt;belongsTo(roleModel::class,'RoleId');
    }

    /**
     * @return mixed
     */
    public function intern($withTrashed = false)
    {
        if($withTrashed == true)
        {
            return $this-&gt;belongsTo(internModel::class, 'InternId')-&gt;withTrashed();
        }

        return $this-&gt;belongsTo(internModel::class,'InternId');
    }

    /**
     * @return mixed
     */
    public function department()
    {
        return $this-&gt;belongsTo(departmentModel::class,'DepartmentId');
    }

    /**
     * @return mixed
     */
    public function mentor()
    {
        return $this-&gt;belongsTo(mentorModel::class,'MentorId');
    }

    /**
     * @return mixed
     */
    public function employees()
    {
        return $this-&gt;hasManyThrough(employeeModel::class,departmentModel::class,'CompanyId','DepartmentId');
    }

    /**
     * @param $role
     * @return bool
     */
    public function hasRole($role)
    {
        if(strtolower($this-&gt;role-&gt;RoleName) == strtolower($role))
        {
            return true;
        }
        return false;
    }
}
</code></pre>