class FactoryBuilder (View source)
Macroable |
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 string | $connection | The database connection on which the model instance should be persisted. | |
protected array | $states | The model states. | |
protected array | $afterMaking | The model after making callbacks. | |
protected array | $afterCreating | The model after creating callbacks. | |
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. |
static void | macro(string $name, object|callable $macro) Register a custom macro. | from Macroable |
static void | mixin(object $mixin, bool $replace = true) Mix another object into the class. | from Macroable |
static bool | hasMacro(string $name) Checks if macro is registered. | from Macroable |
static mixed | __callStatic(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
mixed | __call(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
void | __construct(string $class, string $name, array $definitions, array $states, array $afterMaking, array $afterCreating, Generator $faker) Create an new builder instance. | |
$this | times(int $amount) Set the amount of models you wish to create / make. | |
$this | state(string $state) Set the state to be applied to the model. | |
$this | states(array|mixed $states) Set the states to be applied to the model. | |
$this | connection(string $name) Set the database connection on which the model instance should be persisted. | |
Closure | lazy(array $attributes = []) Create a model and persist it in the database if requested. | |
mixed | create(array $attributes = []) Create a collection of models and persist them to the database. | |
void | store(Collection $results) Set the connection name on the results and store them. | |
mixed | make(array $attributes = []) Create a collection of models. | |
mixed | raw(array $attributes = []) Create an array of raw attribute arrays. | |
mixed | getRawAttributes(array $attributes = []) Get a raw attributes array for the model. | |
Model | makeInstance(array $attributes = []) Make an instance of the model with the given attributes. | |
array | applyStates(array $definition, array $attributes = []) Apply the active states to the model definition array. | |
array | stateAttributes(string $state, array $attributes) Get the state attributes. | |
array | expandAttributes(array $attributes) Expand all attributes to their underlying values. | |
void | callAfterMaking(Collection $models) Run after making callbacks on a collection of models. | |
void | callAfterCreating(Collection $models) Run after creating callbacks on a collection of models. | |
void | callAfter(array $afterCallbacks, Collection $models) Call after callbacks for each model and state. | |
void | callAfterCallbacks(array $afterCallbacks, Model $model, string $state) Call after callbacks for each model and state. | |
bool | stateHasAfterCallback(string $state) Determine if the given state has an "after" callback. |
Register a custom macro.
Mix another object into the class.
Checks if macro is registered.
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 state to be applied to the model.
Set the states to be applied to the model.
Set the database connection on which the model instance should be persisted.
Create a model and persist it in the database if requested.
Create a collection of models and persist them to the database.
Set the connection name on the results and store them.
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.
Get the state attributes.
Expand all attributes to their underlying values.
Run after making callbacks on a collection of models.
Run after creating callbacks on a collection of models.
Call after callbacks for each model and state.
Call after callbacks for each model and state.
Determine if the given state has an "after" callback.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.8/Illuminate/Database/Eloquent/FactoryBuilder.html