Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 24, 2020
1 parent 70a73ab commit 4708e9e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Illuminate/Database/Eloquent/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,13 @@ public function __call($method, $parameters)

$relationship = Str::camel(Str::substr($method, 3));

$relationshipClass = get_class($this->newModel()->{$relationship}()->getRelated());
$relatedModel = get_class($this->newModel()->{$relationship}()->getRelated());

$factory = method_exists($relationshipClass, 'newFactory') && $relationshipClass::newFactory()
? $relationshipClass::newFactory()
: static::factoryForModel($relationshipClass);
if (method_exists($relatedModel, 'newFactory')) {
$factory = $relatedModel::newFactory() ?: static::factoryForModel($relatedModel);
} else {
$factory = static::factoryForModel($relatedModel);
}

if (Str::startsWith($method, 'for')) {
return $this->for($factory->state($parameters[0] ?? []), $relationship);
Expand Down

0 comments on commit 4708e9e

Please sign in to comment.