protected function hasManyThrough(
        $associatedClass,
        $joinModelClass = null,
        $baseTableId = null,
        $associatedTableId = null,
        $firstKey = null,
        $secondKey = null
    ) {
        $baseClass = get_class($this);

        if (is_null($joinModelClass)) {
            $joinModelClass = $this->getJoinClassName($baseClass, $associatedClass);
        }

        // Get table names from each model class
        $classes = [$baseClass, $associatedClass, $joinModelClass];
        list($baseTable, $associatedTable, $joinTable) = $this->filterTableNameFromClass($classes);

        // Get baseTableId & associatedTableId from the given input
        $baseTableId = (is_null($firstKey)) ? $this->getIdColumn($baseClass) : $firstKey;
        $associatedTableId = (is_null($secondKey)) ? $this->getIdColumn($associatedClass) : $secondKey;

        // Get the mappingId and associatedId for joining table
        $mappingId = $this->buildForeignKeyName($baseTableId, $baseTable);
        $associatedTableId = $this->buildForeignKeyName($associatedTableId, $associatedTable);

        return (new $associatedClass())
            ->select("{$associatedTable}.*")
            ->innerJoin($joinTable, [
                    "{$associatedTable}.{$associatedTableId}",
                    '=',
                    "{$joinTable}.{$associatedTableId}", ]
            )->where("{$joinTable}.{$mappingId}", '=', $this->$baseTableId);
    }