Factory (Database\Eloquent)

Factory

class Factory implements ArrayAccess (View source)

Methods

void __construct( Generator $faker)

Create a new factory instance.

static Factory construct( Generator $faker, string|null $pathToFactories = null)

Create a new factory container.

void defineAs( string $class, string $name, callable $attributes)

Define a class with a given short-name.

void define( string $class, callable $attributes, string $name = 'default')

Define a class with a given set of attributes.

mixed create( string $class, array $attributes = array())

Create an instance of the given model and persist it to the database.

mixed createAs( string $class, string $name, array $attributes = array())

Create an instance of the given model and type and persist it to the database.

$this load( string $path)

Load factories from path.

mixed make( string $class, array $attributes = array())

Create an instance of the given model.

mixed makeAs( string $class, string $name, array $attributes = array())

Create an instance of the given model and type.

array rawOf( string $class, string $name, array $attributes = array())

Get the raw attribute array for a given named model.

array raw( string $class, array $attributes = array(), string $name = 'default')

Get the raw attribute array for a given model.

FactoryBuilder of( string $class, string $name = 'default')

Create a builder for the given model.

bool offsetExists( string $offset)

Determine if the given offset exists.

mixed offsetGet( string $offset)

Get the value of the given offset.

void offsetSet( string $offset, callable $value)

Set the given offset to the given value.

void offsetUnset( string $offset)

Unset the value at the given offset.

Details

void __construct( Generator $faker)

Create a new factory instance.

Parameters

Generator $faker

Return Value

void

static Factory construct( Generator $faker, string|null $pathToFactories = null)

Create a new factory container.

Parameters

Generator $faker
string|null $pathToFactories

Return Value

Factory

void defineAs( string $class, string $name, callable $attributes)

Define a class with a given short-name.

Parameters

string $class
string $name
callable $attributes

Return Value

void

void define( string $class, callable $attributes, string $name = 'default')

Define a class with a given set of attributes.

Parameters

string $class
callable $attributes
string $name

Return Value

void

mixed create( string $class, array $attributes = array())

Create an instance of the given model and persist it to the database.

Parameters

string $class
array $attributes

Return Value

mixed

mixed createAs( string $class, string $name, array $attributes = array())

Create an instance of the given model and type and persist it to the database.

Parameters

string $class
string $name
array $attributes

Return Value

mixed

$this load( string $path)

Load factories from path.

Parameters

string $path

Return Value

$this

mixed make( string $class, array $attributes = array())

Create an instance of the given model.

Parameters

string $class
array $attributes

Return Value

mixed

mixed makeAs( string $class, string $name, array $attributes = array())

Create an instance of the given model and type.

Parameters

string $class
string $name
array $attributes

Return Value

mixed

array rawOf( string $class, string $name, array $attributes = array())

Get the raw attribute array for a given named model.

Parameters

string $class
string $name
array $attributes

Return Value

array

array raw( string $class, array $attributes = array(), string $name = 'default')

Get the raw attribute array for a given model.

Parameters

string $class
array $attributes
string $name

Return Value

array

FactoryBuilder of( string $class, string $name = 'default')

Create a builder for the given model.

Parameters

string $class
string $name

Return Value

FactoryBuilder

bool offsetExists( string $offset)

Determine if the given offset exists.

Parameters

string $offset

Return Value

bool

mixed offsetGet( string $offset)

Get the value of the given offset.

Parameters

string $offset

Return Value

mixed

void offsetSet( string $offset, callable $value)

Set the given offset to the given value.

Parameters

string $offset
callable $value

Return Value

void

void offsetUnset( string $offset)

Unset the value at the given offset.

Parameters

string $offset

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.1/Illuminate/Database/Eloquent/Factory.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部