Guest User

Untitled

a guest
Dec 11th, 2017
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. class DatabaseSeeder extends Seeder
  2. {
  3. /**
  4. * Run the database seeds.
  5. *
  6. * @return void
  7. */
  8. public function run()
  9. {
  10. DB::table('users')->insert([
  11. 'name' => str_random(10),
  12. 'email' => str_random(10).'@gmail.com',
  13. 'password' => bcrypt('secret'), //untuk membuat password gunakan bcrypt
  14. ]);
  15.  
  16. //dapat juga menggunakan factory (3 baris pada tabel user)
  17. factory(App\User::class, 3)->create();
  18.  
  19. //atau factory dengan closure atau fungsi anonim melalui fungsi each.
  20. factory(App\User::class, 10)->create()->each(function ($u) {
  21. $u->books()->save(factory(App\Book::class)->make());
  22. });
  23. }
  24. }
Add Comment
Please, Sign In to add comment