database/seeds/PatientTableSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        foreach (\App\Clinic::all() as $clinic) {
            foreach ($clinic->users as $user) {
                factory(App\Patient::class, 10)->make()->each(function (\App\Patient $patient) use ($clinic, $user) {
                    $patient->creator()->associate($user);
                    $patient->clinic()->associate($clinic);
                    $patient->save();
                });
            }
        }
        foreach ($clinic->users as $user) {
            factory(App\Patient::class, 100000)->make()->each(function (\App\Patient $patient) use ($clinic, $user) {
                $patient->creator()->associate($user);
                $patient->clinic()->associate($clinic);
                $patient->save();
            });
        }
    }
public function run ( ) { foreach ( \ App \ Clinic :: all ( ) as $ clinic ) { foreach ( $ clinic -> users as $ user ) { factory ( App \ Patient :: class , 10 ) -> make ( ) -> each ( function ( \ App \ Patient $ patient ) use ( $ clinic , $ user ) { $ patient -> creator ( ) -> associate ( $ user ) ; $ patient -> clinic ( ) -> associate ( $ clinic ) ; $ patient -> save ( ) ; } ) ; } } }
Run the database seeds.
Run the database seeds .
//add patients to the clinic // Uncomment for large number of patient records. //        $clinic = \App\Clinic::find(1); // //        foreach ($clinic->users as $user) { //            //add patients to the clinic //            factory(App\Patient::class, 100000)->make()->each(function (\App\Patient $patient) use ($clinic, $user) { //                $patient->creator()->associate($user); //                $patient->clinic()->associate($clinic); //                $patient->save(); //            }); //        }