Skip to content

Instantly share code, notes, and snippets.

@xiaoysh8
Created July 4, 2018 07:07
Show Gist options
  • Save xiaoysh8/88e8d0ed590b7aa87335576261221aa2 to your computer and use it in GitHub Desktop.
Save xiaoysh8/88e8d0ed590b7aa87335576261221aa2 to your computer and use it in GitHub Desktop.
laravel factory create
factory(App\User::class, 100)->create()->each(function($u) {
$u->profile()->save(factory(App\Models\Profile::class)->make());
$u->wx()->save(factory(App\Models\Wx::class)->make());
for( $i=0; $i<rand(0, 100); $i++){
$u->stats()->save(factory(App\Models\Stat::class)->make());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment