Factory
in package
implements
ArrayAccess
Interfaces, Classes and Traits
- ArrayAccess
Table of Contents
- $definitions : array<string|int, mixed>
- The model definitions in the container.
- $faker : Generator
- The Faker instance for the builder.
- $states : array<string|int, mixed>
- The registered model states.
- __construct() : void
- Create a new factory instance.
- construct() : static
- Create a new factory container.
- create() : mixed
- Create an instance of the given model and persist it to the database.
- createAs() : mixed
- Create an instance of the given model and type and persist it to the database.
- define() : $this
- Define a class with a given set of attributes.
- defineAs() : $this
- Define a class with a given short-name.
- load() : $this
- Load factories from path.
- make() : mixed
- Create an instance of the given model.
- makeAs() : mixed
- Create an instance of the given model and type.
- of() : FactoryBuilder
- Create a builder for the given model.
- offsetExists() : bool
- Determine if the given offset exists.
- offsetGet() : mixed
- Get the value of the given offset.
- offsetSet() : void
- Set the given offset to the given value.
- offsetUnset() : void
- Unset the value at the given offset.
- raw() : array<string|int, mixed>
- Get the raw attribute array for a given model.
- rawOf() : array<string|int, mixed>
- Get the raw attribute array for a given named model.
- state() : $this
- Define a state with a given set of attributes.
Properties
$definitions
The model definitions in the container.
protected
array<string|int, mixed>
$definitions
= []
$faker
The Faker instance for the builder.
protected
Generator
$faker
$states
The registered model states.
protected
array<string|int, mixed>
$states
= []
Methods
__construct()
Create a new factory instance.
public
__construct(Generator $faker) : void
Parameters
- $faker : Generator
Return values
void —construct()
Create a new factory container.
public
static construct(Generator $faker[, string|null $pathToFactories = null ]) : static
Parameters
- $faker : Generator
- $pathToFactories : string|null = null
Return values
static —create()
Create an instance of the given model and persist it to the database.
public
create(string $class[, array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $class : string
- $attributes : array<string|int, mixed> = []
Return values
mixed —createAs()
Create an instance of the given model and type and persist it to the database.
public
createAs(string $class, string $name[, array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $class : string
- $name : string
- $attributes : array<string|int, mixed> = []
Return values
mixed —define()
Define a class with a given set of attributes.
public
define(string $class, callable $attributes[, string $name = 'default' ]) : $this
Parameters
- $class : string
- $attributes : callable
- $name : string = 'default'
Return values
$this —defineAs()
Define a class with a given short-name.
public
defineAs(string $class, string $name, callable $attributes) : $this
Parameters
- $class : string
- $name : string
- $attributes : callable
Return values
$this —load()
Load factories from path.
public
load(string $path) : $this
Parameters
- $path : string
Return values
$this —make()
Create an instance of the given model.
public
make(string $class[, array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $class : string
- $attributes : array<string|int, mixed> = []
Return values
mixed —makeAs()
Create an instance of the given model and type.
public
makeAs(string $class, string $name[, array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $class : string
- $name : string
- $attributes : array<string|int, mixed> = []
Return values
mixed —of()
Create a builder for the given model.
public
of(string $class[, string $name = 'default' ]) : FactoryBuilder
Parameters
- $class : string
- $name : string = 'default'
Return values
FactoryBuilder —offsetExists()
Determine if the given offset exists.
public
offsetExists(string $offset) : bool
Parameters
- $offset : string
Return values
bool —offsetGet()
Get the value of the given offset.
public
offsetGet(string $offset) : mixed
Parameters
- $offset : string
Return values
mixed —offsetSet()
Set the given offset to the given value.
public
offsetSet(string $offset, callable $value) : void
Parameters
- $offset : string
- $value : callable
Return values
void —offsetUnset()
Unset the value at the given offset.
public
offsetUnset(string $offset) : void
Parameters
- $offset : string
Return values
void —raw()
Get the raw attribute array for a given model.
public
raw(string $class[, array<string|int, mixed> $attributes = [] ][, string $name = 'default' ]) : array<string|int, mixed>
Parameters
- $class : string
- $attributes : array<string|int, mixed> = []
- $name : string = 'default'
Return values
array<string|int, mixed> —rawOf()
Get the raw attribute array for a given named model.
public
rawOf(string $class, string $name[, array<string|int, mixed> $attributes = [] ]) : array<string|int, mixed>
Parameters
- $class : string
- $name : string
- $attributes : array<string|int, mixed> = []
Return values
array<string|int, mixed> —state()
Define a state with a given set of attributes.
public
state(string $class, string $state, callable|array<string|int, mixed> $attributes) : $this
Parameters
- $class : string
- $state : string
- $attributes : callable|array<string|int, mixed>