Tuesday, February 28, 2017

Define factory with field = id value

I want to define factory with position field = id value. Is it possible?

For example:

$factory->define(App\Models\Category::class, function (Faker\Generator $faker) {

    return [

        'name' => $faker->name,
        'display' => 1,
        'position' => function (array $category) {

            return $category['id'];
        },
    ];
});




via Evgeniy

Advertisement