'patient'.$x.'@mail.com', 'password' => Hash::make('password') ]); $user->assignRole('patient'); $genders = collect(['male','female']); $conditions = collect(['normal','mi']); $patient = Patient::create([ 'id' => fake()->uuid(), 'user_id' => $user->id, 'fullname' => fake()->name(), 'address' => fake()->address(), 'phone' => fake()->phoneNumber(), 'emergency_phone' => fake()->phoneNumber(), 'gender' => $genders->shuffle()->first(), 'age' => rand(9,70), 'device_id' => fake()->uuid(), 'condition' => $conditions->shuffle()->first(), ]); } $patients = Patient::all(); foreach ($patients as $p){ $doctor = Doctor::inRandomOrder()->first(); $p->doctors()->attach($doctor); } } }