Exemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @param $request
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request, $id)
 {
     $request->merge(['team_id' => $id]);
     $request = $this->getPaginateRequest(Requests\UserPaginateRequest::class, $request->query());
     $paginator = $this->getPaginator($this->user->query(), $request);
     return response()->json($paginator->toArray());
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $superUser = User::firstOrCreate(['first_name' => 'SUPER', 'last_name' => 'ADMIN', 'email' => '*****@*****.**']);
     $superUser->update(['password' => bcrypt('secret')]);
     $adminRole = Role::whereName('SUPER')->first();
     UserRole::firstOrCreate(['user_id' => $superUser->id, 'role_id' => $adminRole->id]);
     factory(User::class, 100)->create()->each(function ($user) {
         //$user->posts()->save(factory(App\Post::class)->make());
     });
 }
Exemplo n.º 3
0
 /**
  * @covers \Ohio\Core\User\User::__toString
  * @covers \Ohio\Core\User\User::setEmailAttribute
  * @covers \Ohio\Core\User\User::setIsVerifiedAttribute
  * @covers \Ohio\Core\User\User::setIsActiveAttribute
  * @covers \Ohio\Core\User\User::setFirstNameAttribute
  * @covers \Ohio\Core\User\User::setLastNameAttribute
  * @covers \Ohio\Core\User\User::setMiAttribute
  * @covers \Ohio\Core\User\User::setPasswordAttribute
  * @covers \Ohio\Core\User\User::setUsernameAttribute
  * @covers \Ohio\Core\User\User::getAuthIdentifierName
  * @covers \Ohio\Core\User\User::getAuthIdentifier
  * @covers \Ohio\Core\User\User::getAuthPassword
  * @covers \Ohio\Core\User\User::getRememberToken
  * @covers \Ohio\Core\User\User::setRememberToken
  * @covers \Ohio\Core\User\User::getRememberTokenName
  * @covers \Ohio\Core\User\User::getReminderEmail
  * @covers \Ohio\Core\User\User::roles
  * @covers \Ohio\Core\User\User::hasRole
  */
 public function test()
 {
     $user = factory(User::class)->make();
     $role = factory(Role::class)->make(['name' => 'test']);
     User::unguard();
     $user->email = ' TEST@TEST.COM ';
     $user->is_verified = 1;
     $user->is_active = 1;
     $user->first_name = ' test ';
     $user->last_name = ' test ';
     $user->mi = ' test ';
     $user->password = '******';
     $user->username = '******';
     $attributes = $user->getAttributes();
     # roles relationship
     $this->assertInstanceOf(BelongsToMany::class, $user->roles());
     $user->roles->add(factory(Role::class)->make(['name' => 'test']));
     $this->assertEquals(1, $user->roles->count());
     # hasRole
     $this->assertTrue($user->hasRole('test'));
     $this->assertFalse($user->hasRole('other-role'));
     $this->assertFalse($user->hasRole('super'));
     $user->roles->add(factory(Role::class)->make(['name' => 'super']));
     $this->assertEquals(2, $user->roles->count());
     $this->assertTrue($user->hasRole('super'));
     # setters
     $this->assertEquals('*****@*****.**', $user->email);
     $this->assertEquals('*****@*****.**', $user->__toString());
     $this->assertEquals(true, $attributes['is_verified']);
     $this->assertEquals(true, $attributes['is_active']);
     $this->assertEquals('TEST', $attributes['last_name']);
     $this->assertEquals('TEST', $attributes['first_name']);
     $this->assertEquals('T', $attributes['mi']);
     $this->assertTrue(Hash::check('test', $attributes['password']));
     $this->assertEquals('test', $attributes['username']);
     # Authenticatable functions
     $user->id = 1;
     $user->setRememberToken('test');
     $attributes = $user->getAttributes();
     $this->assertEquals('test', $attributes['remember_token']);
     $this->assertNotEmpty($user->getAuthIdentifierName());
     $this->assertNotEmpty($user->getAuthIdentifier());
     $this->assertNotEmpty($user->getAuthPassword());
     $this->assertNotEmpty($user->getRememberToken());
     $this->assertNotEmpty($user->getRememberTokenName());
     $this->assertEquals('*****@*****.**', $user->getReminderEmail());
 }
Exemplo n.º 4
0
 public function item($id)
 {
     return User::find($id);
 }
Exemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Requests\CreateRequest $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\CreateRequest $request)
 {
     $user = $this->user->create($request->all());
     return response()->json($user);
 }