Exemple #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['name' => 'Dwi Prabowo', 'email' => '*****@*****.**', 'password' => bcrypt('asdfasdf'), 'remember_token' => str_random(10), 'gender' => 1]);
     Role::create(['name' => 'admin', 'label' => 'The admin of the system']);
     Permission::create(['name' => 'dashboard', 'label' => 'User has right to access admin dashboard']);
     Role::whereName('admin')->first()->assign(Permission::whereName('dashboard')->first());
     User::whereEmail('*****@*****.**')->first()->assign(Role::whereName('admin')->first());
     User::create(['name' => 'Owl Jpr', 'email' => '*****@*****.**', 'password' => bcrypt('asdfasdf'), 'remember_token' => str_random(10), 'gender' => 1]);
     for ($i = 0; $i < 10; $i++) {
         factory(User::class)->create();
     }
 }
Exemple #2
0
 public function assign($role)
 {
     return $this->roles()->save(is_string($role) ? Role::whereName($role)->firstOrFail() : $role);
 }