parseModel($model); $through = $this->parseModel($through); $localKey = $localKey ?: $this->getPk(); $foreignKey = $foreignKey ?: $this->getForeignKey($this->name); $throughKey = $throughKey ?: $this->getForeignKey((new $through())->getName()); $throughPk = $throughPk ?: (new $through())->getPk(); return new HasManyThrough($this, $model, $through, $foreignKey, $throughKey, $localKey, $throughPk); } }