diff --git a/src/Illuminate/Database/Eloquent/Factories/HasFactory.php b/src/Illuminate/Database/Eloquent/Factories/HasFactory.php index 496f00f3f0fc..7132b0659f92 100644 --- a/src/Illuminate/Database/Eloquent/Factories/HasFactory.php +++ b/src/Illuminate/Database/Eloquent/Factories/HasFactory.php @@ -12,8 +12,20 @@ trait HasFactory */ public static function factory(...$parameters) { - return Factory::factoryForModel(get_called_class()) + $factory = static::newFactory() ?: Factory::factoryForModel(get_called_class()); + + return $factory ->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null) ->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? [])); } + + /** + * Create a new factory instance for the model. + * + * @return \Illuminate\Database\Eloquent\Factories\Factory + */ + public static function newFactory() + { + // + } }