Factory
class Factory implements ArrayAccess (View source)
Methods
Create a new factory instance.
Create a new factory container.
Define a class with a given short-name.
Define a class with a given set of attributes.
Create an instance of the given model and persist it to the database.
Create an instance of the given model and type and persist it to the database.
Load factories from path.
Create an instance of the given model.
Create an instance of the given model and type.
Get the raw attribute array for a given named model.
Get the raw attribute array for a given model.
Create a builder for the given model.
Determine if the given offset exists.
Get the value of the given offset.
Set the given offset to the given value.
Unset the value at the given offset.
Details
at line line 43
static
Factory
construct(
Generator $faker,
string|null $pathToFactories = null)
Create a new factory container.
at line line 58
void
defineAs(
string $class,
string $name,
callable $attributes)
Define a class with a given short-name.
at line line 71
void
define(
string $class,
callable $attributes,
string $name = 'default')
Define a class with a given set of attributes.
at line line 83
mixed
create(
string $class,
array $attributes = array())
Create an instance of the given model and persist it to the database.
at line line 96
mixed
createAs(
string $class,
string $name,
array $attributes = array())
Create an instance of the given model and type and persist it to the database.
at line line 127
mixed
make(
string $class,
array $attributes = array())
Create an instance of the given model.
at line line 140
mixed
makeAs(
string $class,
string $name,
array $attributes = array())
Create an instance of the given model and type.
at line line 153
array
rawOf(
string $class,
string $name,
array $attributes = array())
Get the raw attribute array for a given named model.
at line line 166
array
raw(
string $class,
array $attributes = array(),
string $name = 'default')
Get the raw attribute array for a given model.
at line line 180
FactoryBuilder
of(
string $class,
string $name = 'default')
Create a builder for the given model.
at line line 214
void
offsetSet(
string $offset,
callable $value)
Set the given offset to the given value.