2 years ago

#6725

test-img

Oybek Odilov

Laravel Seeding - How to share a foreign key to child

I want to share user_id to the Payment factory. I need it.

My DatabaseSeeder's run function's content:

\App\Models\User::factory()->count(10)->has(
    \App\Models\Client::factory()->count(30)->has(
        \App\Models\Payment::factory()->count(30)
    )
)->create();

How I can implement this?

php

laravel

relation

seeding

0 Answers

Your Answer

Accepted video resources