Ejemplo n.º 1
0
 /**
  * Should create a non-staff user if the --staff option is not given.
  */
 public function testDoesNotCreateStaffUserWithoutFlag()
 {
     $this->roleResource->expects($this->never())->method('mustFindByName');
     $this->userResource->expects($this->never())->method('roles');
     $tester = $this->commandTester($this->makeUser);
     $tester->execute([]);
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $staff = Role::create(['name' => Role::STAFF]);
     $developer = User::create(['name' => 'Developer', 'email' => '*****@*****.**', 'password' => bcrypt('developer')]);
     $developer->roles()->sync([$staff->id]);
     $developer->save();
 }
Ejemplo n.º 3
0
 /**
  * @return User
  */
 private function fetchLatestUser() : User
 {
     $latestUserResource = User::with('roles')->orderBy('updated_at', 'desc')->first();
     return $latestUserResource ? $latestUserResource : new User();
 }
Ejemplo n.º 4
0
 /**
  * Should use roles to determine if user is staff.
  */
 public function testIsStaff()
 {
     $this->user->setAttribute('roles', []);
     $this->assertFalse($this->user->isStaff());
 }
 /**
  * @return Collection|User[]
  */
 private function staffUsers() : Collection
 {
     return $this->userResource->whereHas('roles', function (Builder $roles) {
         $roles->where('name', '=', Role::STAFF);
     })->get() ?? new Collection();
 }
Ejemplo n.º 6
0
 /**
  * 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' => bcrypt($data['password'])]);
 }