Skip to content

Commit 4a95372

Browse files
committed
add new factory method
1 parent e9d9b93 commit 4a95372

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Illuminate/Database/Eloquent/Factories/HasFactory.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@ trait HasFactory
1212
*/
1313
public static function factory(...$parameters)
1414
{
15-
return Factory::factoryForModel(get_called_class())
15+
$factory = static::newFactory() ?: Factory::factoryForModel(get_called_class());
16+
17+
return $factory
1618
->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null)
1719
->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? []));
1820
}
21+
22+
/**
23+
* Create a new factory instance for the model.
24+
*
25+
* @return \Illuminate\Database\Eloquent\Factories\Factory
26+
*/
27+
public static function newFactory()
28+
{
29+
//
30+
}
1931
}

0 commit comments

Comments
 (0)