public function run() { /* * Create user and role ADMIN */ $user = User::create(['name' => 'admin', 'email' => '*****@*****.**', 'password' => 'admin']); $adminRole = Role::create(['name' => 'Admin', 'slug' => 'admin']); $user->attachRole($adminRole); /* * Create user and role MODERATOR */ $user = User::create(['name' => 'moderator', 'email' => '*****@*****.**', 'password' => 'moderator']); $moderatorRole = Role::create(['name' => 'Moderator', 'slug' => 'moderator']); $user->attachRole($moderatorRole); /* * Create user and role USER */ $user = User::create(['name' => 'user', 'email' => '*****@*****.**', 'password' => 'user']); $userRole = Role::create(['name' => 'User', 'slug' => 'user']); $user->attachRole($userRole); /* * Create user and role badUser - not verified user */ $user = User::create(['name' => 'test', 'email' => '*****@*****.**', 'password' => 'test']); $badUserRole = Role::create(['name' => 'badUser', 'slug' => 'bad.user']); $user->attachRole($badUserRole); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => $data['password']]); }