mercredi 24 juillet 2019

How to make multiple laravel factory instead of create

How to "make" multiple factory objects instead of using "create" function?

As I don't want to store the data into the database. I'd like to use make method instead of create method.

$factory->defineAs(App\Post::class, '12345', function () {
    return [
        [
            'user_id' => function () {
                return factory(App\User::class)->make()->id;
            },
            'status' => App\Post::STATUS_MODIFIABLE,
            'created_at' => '2019-07-25 10:50:00',
        ],
        [
            'user_id' => function () {
                return factory(App\User::class)->make()->id;
            },
            'status' => App\Post::STATUS_MODIFIABLE,
            'created_at' => '2019-07-25 10:50:00',
        ],
    ];
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire