/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->delete();
     $adminRole = Role::whereName('administrator')->first();
     $userRole = Role::whereName('user')->first();
     $user = User::firstOrCreate(['email' => '*****@*****.**']);
     $user->name = 'Jill';
     $user->email = '*****@*****.**';
     $user->password = \Hash::make('helloworld');
     $user->save();
     $user->assignRole($adminRole);
     $profile = new UserProfile();
     $user->profile()->save($profile);
     $user = User::firstOrCreate(['email' => '*****@*****.**']);
     $user->name = 'Jamal';
     $user->email = '*****@*****.**';
     $user->password = \Hash::make('helloworld');
     $user->save();
     $user->assignRole($userRole);
     $profile = new UserProfile();
     $user->profile()->save($profile);
     $user = User::firstOrCreate(['email' => '*****@*****.**']);
     $user->name = 'Kakha Urigashvili';
     $user->email = '*****@*****.**';
     $user->password = \Hash::make('123');
     $user->save();
     $user->assignRole($adminRole);
     $profile = new UserProfile();
     $user->profile()->save($profile);
 }
 public function run()
 {
     DB::table('roles')->delete();
     Role::create(['name' => 'user']);
     Role::create(['name' => 'administrator']);
 }
示例#3
0
 public function assignDefaultRole()
 {
     $userRole = Role::whereName('user')->first();
     return $this->roles()->attach($userRole);
 }