Multiple with() function in Laravel Query: Laravel 5.2.37
<p><strong>Model 1</strong></p>

<pre><code>class RoleModel extends Model {

    public $table = 'tblrole';
    public $primaryKey = 'RoleID';
    public $timestamps = true;

    public function RoleBasedPermissions() {
        return $this-&gt;hasMany('App\Models\Role\RolePermissionModel', 'RoleID', 'RoleID');
    }
}
</code></pre>

<p><strong>Model 2</strong></p>

<pre><code>class RolePermissionModel extends Model
{
    public $table = 'tblrolepermission';
    public $primaryKey = 'RolePermissionID';
    public $timestamps = false;

    public function Permission() {
        return $this-&gt;hasOne('App\Models\Role\RolePermissionModel', 
            'PermissionID', 'PermissionID');
    }

    public function Role() {
        return $this-&gt;hasOne('App\Models\Role\RoleModel', 
            'RoleID', 'RoleID');
    }
}
</code></pre>

<p><strong>Model 3</strong></p>

<pre><code>class PermissionModel extends Model
{
    public $table = 'tblpermission';
    public $primaryKey = 'PermissionID';
    public $timestamps = false;

    public function Module() {
        return $this-&gt;hasOne('App\Models\Role\ModuleModel', 
            'ModuleID', 'ModuleID');
    }

    public function Action() {
        return $this-&gt;hasOne('App\Models\Role\ActionModel', 
            'ActionID', 'ActionID');
    }
}
</code></pre>

<p><strong>My Query is below</strong></p>

<pre><code>$data = RoleModel
    ::where('RoleID', $RoleID)
    -&gt;with('RoleBasedPermissions')
    -&gt;with('RoleBasedPermissions.Permission')
    -&gt;with('RoleBasedPermissions.Permission.Module')
    -&gt;get();  
</code></pre>

<p><strong>Error</strong></p>

<blockquote>
  <p>Call to undefined method Illuminate\Database\Query\Builder::Module()</p>
</blockquote>

<p><strong>Details</strong></p>

<p>Issue is in this Query part <code>-&gt;with('RoleBasedPermissions.Permission.Module')</code></p>

<p>Am I missing something?</p>