Factory
abstract class Factory
Base abstract class for all factory classes.
Properties
| protected array | $afterCreatingCallbacks | Array containing callbacks that are used after database record is successfully saved. |
|
| protected int | $count | Value for how many insertions to be performed by factory. |
|
| protected FactoryFaker | $faker | Instance of Faker\Factory object. |
|
| protected string | $modelName | The model used by the child factory class. |
|
| protected array | $states | States for overriding definition. |
Methods
Constructor for Faker class. Should be called by any child class that overrides this constructor.
Define the model's default state.
Adds callback to afterCreatingCallbacks array.
Helper function for satisfying complexity or length requirements.
Create a record(s) in the database.
Insert data into the database table.
Calls all registered afterCreating callbacks associated with a factory.
Calls state callback functions.
Details
at line 52
__construct()
Constructor for Faker class. Should be called by any child class that overrides this constructor.
at line 62
abstract protected array
definition()
Define the model's default state.
at line 70
Factory
afterCreating(callable $callback)
Adds callback to afterCreatingCallbacks array.
at line 81
protected string
append()
Helper function for satisfying complexity or length requirements.
at line 97
array|object
create(array $attributes = [])
Create a record(s) in the database.
at line 125
protected Factory
configure()
Configure function used for registering afterCreating callbacks.
at line 135
Factory
count(int $count)
Specify number of records to insert into the database.
at line 147
static Factory
factory(mixed ...$params)
Returns instance of new child factory class.
at line 159
protected object|null
insert(array $data, string $modelName)
Insert data into the database table.
at line 192
protected void
invokeAfterCreatingCallbacks(object $model)
Calls all registered afterCreating callbacks associated with a factory.
at line 207
protected array
invokeStateCallbacks(array $attributes, array $data)
Calls state callback functions.
at line 222
Factory
sequence(array ...$sequence)
Registers sequence callbacks.
at line 236
Factory
state(callable $state)
Manages state for values of keys that should be overridden by state functions.