FactoryBuilder
class FactoryBuilder
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected array | $definitions | The model definitions in the container. |
|
protected string | $class | The model being built. |
|
protected string | $name | The name of the model being built. |
|
protected array | $states | The model states. |
|
protected array | $activeStates | The states to apply. |
|
protected Generator | $faker | The Faker instance for the builder. |
|
protected int|null | $amount | The number of models to build. |
Methods
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create an new builder instance.
Set the amount of models you wish to create / make.
Set the states to be applied to the model.
Create a collection of models and persist them to the database.
Create a collection of models.
Create an array of raw attribute arrays.
Get a raw attributes array for the model.
Make an instance of the model with the given attributes.
Apply the active states to the model definition array.
Expand all attributes to their underlying values.
Details
in
Macroable at line 24
static void
macro(string $name, callable $macro)
Register a custom macro.
in
Macroable at line 35
static bool
hasMacro(string $name)
Checks if macro is registered.
in
Macroable at line 49
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 71
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 72
void
__construct(string $class, string $name, array $definitions, array $states, Generator $faker)
Create an new builder instance.
at line 87
$this
times(int $amount)
Set the amount of models you wish to create / make.
at line 100
$this
states(array|mixed $states)
Set the states to be applied to the model.
at line 113
Closure
lazy(array $attributes = [])
Create a model and persist it in the database if requested.
at line 126
mixed
create(array $attributes = [])
Create a collection of models and persist them to the database.
at line 145
protected void
store(Collection $results)
Set the connection name on the results and store them.
at line 160
mixed
make(array $attributes = [])
Create a collection of models.
at line 181
mixed
raw(array $attributes = [])
Create an array of raw attribute arrays.
at line 202
protected mixed
getRawAttributes(array $attributes = [])
Get a raw attributes array for the model.
at line 222
protected Model
makeInstance(array $attributes = [])
Make an instance of the model with the given attributes.
at line 242
protected array
applyStates(array $definition, array $attributes = [])
Apply the active states to the model definition array.
at line 264
protected array
expandAttributes(array $attributes)
Expand all attributes to their underlying values.