class ProfileImageFactory extends Factory

Factory for generating new profile images.

Properties

protected array $afterCreatingCallbacks

Array containing callbacks that are used after database record is successfully saved.

from  Factory
protected int $count

Value for how many insertions to be performed by factory.

from  Factory
protected FactoryFaker $faker

Instance of Faker\Factory object.

from  Factory
protected string $modelName
protected array $states

States for overriding definition.

from  Factory
private int $userId

Methods

__construct(int $userId)

Constructor for Faker class. Should be called by any child class that overrides this constructor.

array
definition()

Define the model's default state.

afterCreating(callable $callback)

Adds callback to afterCreatingCallbacks array.

from  Factory
string
append()

Helper function for satisfying complexity or length requirements.

from  Factory
array|object
create(array $attributes = [])

Create a record(s) in the database.

from  Factory
configure()

Configure function used for registering afterCreating callbacks.

from  Factory
count(int $count)

Specify number of records to insert into the database.

from  Factory
static Factory
factory(mixed ...$params)

Returns instance of new child factory class.

from  Factory
object|null
insert(array $data, string $modelName)

Insert data into the database table.

from  Factory
void
invokeAfterCreatingCallbacks(object $model)

Calls all registered afterCreating callbacks associated with a factory.

from  Factory
array
invokeStateCallbacks(array $attributes, array $data)

Calls state callback functions.

from  Factory
sequence(array ...$sequence)

Registers sequence callbacks.

from  Factory
state(callable $state)

Manages state for values of keys that should be overridden by state functions.

from  Factory

Details

at line 23
__construct(int $userId)

Constructor for Faker class. Should be called by any child class that overrides this constructor.

Parameters

int $userId

The user_id for the profile image.

at line 34
protected array definition()

Define the model's default state.

Return Value

array

in Factory at line 70
Factory afterCreating(callable $callback)

Adds callback to afterCreatingCallbacks array.

Parameters

callable $callback

The anonymous callback for afterCreating.

Return Value

Factory

in Factory at line 81
protected string append()

Helper function for satisfying complexity or length requirements.

Return Value

string

A string containing a random digit, a lower case character, an upper case character, and a special character.

in Factory at line 97
array|object create(array $attributes = [])

Create a record(s) in the database.

Parameters

array $attributes

The an associative array attributes used to override default definition values.

Return Value

array|object

The array of models that were created or a single object model if just one record is inserted.

in Factory at line 125
protected Factory configure()

Configure function used for registering afterCreating callbacks.

Return Value

Factory

in Factory at line 135
Factory count(int $count)

Specify number of records to insert into the database.

Parameters

int $count

The number of records to create.

Return Value

Factory

in Factory at line 147
static Factory factory(mixed ...$params)

Returns instance of new child factory class.

Parameters

mixed ...$params

Params for factory.

Return Value

Factory

The child factory class.

in Factory at line 159
protected object|null insert(array $data, string $modelName)

Insert data into the database table.

Parameters

array $data

Data to be saved in new database record.

string $modelName

The name of the model to reference correct table.

Return Value

object|null

The model object if save is successful. Otherwise, we return null.

in Factory at line 192
protected void invokeAfterCreatingCallbacks(object $model)

Calls all registered afterCreating callbacks associated with a factory.

Parameters

object $model

The parent model

Return Value

void

in Factory at line 207
protected array invokeStateCallbacks(array $attributes, array $data)

Calls state callback functions.

Parameters

array $attributes

The attributes used to override default definition values.

array $data

Data to be saved in new database record.

Return Value

array

$data The data that contains values that overrides defaults found in definition.

in Factory at line 222
Factory sequence(array ...$sequence)

Registers sequence callbacks.

Parameters

array ...$sequence

Sequence of values to alternate between for consecutive record creations when using count.

Return Value

Factory

in Factory at line 236
Factory state(callable $state)

Manages state for values of keys that should be overridden by state functions.

Parameters

callable $state

The anonymous function for overriding a value for a specified key.

Return Value

Factory