In a UserFactory, I need to write a state method that attaches the user being created (or created) to a many to many "role" object
In a UserFactory, I need to write a state method that attaches the user being created (or created) to a many to many "role" object Problem Description: I would want to write something like this: class UserFactory extends Factory { public function withRoles(array $roles) { $factory->state(function (array $attributes) use ($roles) { $user = User::find($attributes[‘id’]); $roles … Read more