1 year ago

Model events in database seeder

Posted 1 year ago by Cinek

Hi, I have one confusion. I have 2 models: User and Group. Group have user_id which means owner of this group. I fill this ID in GroupObserver in creating function


I have problem because it will fail:

        factory(\App\Models\Group::class, 10)->create();

while seeding there is not logged user. I assigned user to group in GroupFactory and disable all events on Group model but I think there's a better way to workarround this problem.

Please sign in or create an account to participate in this conversation.