A
A
Artem00712018-06-01 14:11:05
Laravel
Artem0071, 2018-06-01 14:11:05

How can I get id's from the factory?

There is this code:

$options = factory(\App\Models\V1\Shop\Item\Option::class, 20)->make([
                        'shop_id' => $shop->id
                    ]);

                    Log::info($options);

The output is the desired array, but it is without an id:
[2018-06-01 11:08:15] local.INFO: [{"shop_id":"8af50f5f-92b1-45c5-b4aa-8665340273b5","title":"...","description":null,"price":0}, ...]

How can you get these IDs?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2018-06-01
@alexey-m-ukolov

factory()->make()- create objects in memory.
factory()->create()- create objects in memory and store them in the database.
No entry in the database - no ID.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question