Skip to content

Commit

Permalink
Update sources
Browse files Browse the repository at this point in the history
  • Loading branch information
bastien-phi committed Aug 27, 2020
1 parent b2ea065 commit fe020f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ abstract public function definition();
*/
public static function new($attributes = [])
{
return (new static)->state($attributes);
return (new static)->state($attributes)->configure();
}

/**
Expand All @@ -153,7 +153,17 @@ public static function new($attributes = [])
*/
public static function times(int $count)
{
return new static($count);
return static::new()->count($count);
}

/**
* Configure the factory.
*
* @return $this
*/
public function configure()
{
return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/HasFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait HasFactory
public static function factory(...$parameters)
{
return Factory::factoryForModel(get_called_class())
->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : 1)
->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null)
->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? []));
}
}

0 comments on commit fe020f9

Please sign in to comment.