Ejemplo n.º 1
0
 /**
  * @param User  $guardian
  * @param array $attributes
  *
  * @return static
  */
 public function create(User $guardian, array $attributes)
 {
     $attributes['guardian_id'] = $guardian->id;
     DB::beginTransaction();
     $player = Player::create($attributes);
     if ($guardian->isNotA(Role::GUARDIAN)) {
         $role = Role::where('name', Role::GUARDIAN)->firstOrFail();
         $guardian->assign($role);
     }
     DB::commit();
     return $player;
 }
Ejemplo n.º 2
0
 public function setupAsHeadCoach()
 {
     $this->headCoach = User::where('email', DatabaseSeeder::HEAD_COACH_EMAIL)->first();
     $this->group = Group::where('name', DatabaseSeeder::GROUP_NAME)->first();
     $this->season = Season::orderBy('id', 'DESC')->first();
     $this->actingAs($this->headCoach)->withSession([SessionManager::GROUP => $this->group->toArray(), SessionManager::SEASON => $this->season->toArray()]);
 }
Ejemplo n.º 3
0
 public static function boot()
 {
     parent::boot();
     // assign a guid for each model
     static::creating(function ($tournamentQuizmaster) {
         $tournamentQuizmaster->guid = Uuid::uuid4();
         return true;
     });
     // Make sure the user has the quizmaster role
     // Using a saved event since the user could be assigned
     // after the initial creation
     static::saved(function ($tournamentQuizmaster) {
         $user = $tournamentQuizmaster->user;
         // if no user is linked, try to find one
         if (is_null($user)) {
             $user = User::where('email', $tournamentQuizmaster->email)->first();
         }
         if (!is_null($user)) {
             // label the user as a quizmaster
             if ($user->isNotA(Role::QUIZMASTER)) {
                 $role = Role::where('name', Role::QUIZMASTER)->firstOrFail();
                 $user->assign($role);
             }
             // associate the user with the quizmaster
             if ($tournamentQuizmaster->user_id == null) {
                 $tournamentQuizmaster->update(['user_id' => $user->id]);
             }
         }
     });
 }
Ejemplo n.º 4
0
 public function postTransferOwnership(AdminOnlyRequest $request, $groupId)
 {
     $newOwner = User::findOrFail($request->input('user_id'));
     $group = Group::findOrFail($groupId);
     $group->setOwner($newOwner);
     return redirect('/admin/groups/' . $groupId)->withFlashSuccess('Ownership has been transferred and head coaches have been notified');
 }
Ejemplo n.º 5
0
 /**
  * @test
  */
 public function canRemoveUsers()
 {
     $guardian = User::where('email', DatabaseSeeder::GUARDIAN_EMAIL)->first();
     $this->setupAsHeadCoach();
     $this->group()->addHeadCoach($guardian);
     $this->visit('/group/' . $this->group()->id . '/settings/users')->see($guardian->full_name)->click('Remove')->see('User has been removed');
     $this->assertEquals(1, $this->group()->users()->count());
 }
 /**
  * Handle the event.
  *
  * @param User $user
  *
  * @return void
  */
 public function handle(User $user)
 {
     if (DatabaseSeeder::isSeeding() || app()->environment('testing')) {
         return;
     }
     $list = $this->mailchimp->mailingList(env('MAILCHIMP_LIST_ID'));
     // We can't update an email address via the API, so we have to unsubscribe them
     if ($user->isDirty('email')) {
         $list->unsubscribe($user->getOriginal('email'));
     }
     // need to make sure their interests are up to date
     $interests = [];
     foreach (Role::whereNotNull('mailchimp_interest_id')->get() as $role) {
         $interests[$role->mailchimp_interest_id] = $user->isA($role->name);
     }
     // will add or update depending on whether the email addresses
     $list->updateSubscriber($user->email, $user->first_name, $user->last_name, $interests);
     // also do this for each group
     // group members don't get classified by interest
     foreach ($user->groups()->active()->get() as $group) {
         if ($group->settings->shouldUpdateSubscribers()) {
             /** @var Easychimp $mailchimp */
             $mailchimp = app(Easychimp::class, [$group->settings->mailchimpKey()]);
             $list = $mailchimp->mailingList($group->settings->mailchimpListId());
             if ($user->isDirty('email')) {
                 $list->unsubscribe($user->getOriginal('email'));
             }
             $list->updateSubscriber($user->email, $user->first_name, $user->last_name);
         }
     }
     $this->delete();
 }
 /** @test */
 public function onlyDeletesUnconfirmedAccounts()
 {
     $userCount = User::count();
     $shouldBeDeletedCount = User::where('status', User::STATUS_UNCONFIRMED)->count();
     $this->assertGreaterThan(0, $shouldBeDeletedCount);
     $this->artisan(\BibleBowl\Users\CleanupOrphanAccounts::COMMAND);
     $this->assertEquals(0, User::where('status', User::STATUS_UNCONFIRMED)->count());
     $this->assertEquals($userCount - $shouldBeDeletedCount, User::count());
 }
Ejemplo n.º 8
0
 /**
  * @test
  */
 public function updateNotifications()
 {
     $this->visit('/account/notifications')->see('Notification')->see('Preferences')->uncheck('#notifyWhenUserJoinsGroup')->press('Save')->see('Your changes were saved');
     $userSettings = User::findOrFail($this->headCoach()->id)->settings;
     $this->assertFalse($userSettings->shouldBeNotifiedWhenUserJoinsGroup());
     $this->visit('/account/notifications')->check('#notifyWhenUserJoinsGroup')->press('Save')->see('Your changes were saved');
     $userSettings = User::findOrFail($this->headCoach()->id)->settings;
     $this->assertTrue($userSettings->shouldBeNotifiedWhenUserJoinsGroup());
 }
Ejemplo n.º 9
0
 /**
  * Get a validator for an incoming registration request.
  *
  * @param array $data
  *
  * @return \Illuminate\Contracts\Validation\Validator
  */
 public function validator(array $data)
 {
     $rules = array_only(User::validationRules(), ['email', 'password']);
     $rules['password'] = '******' . $rules['password'];
     if (!App::environment('local', 'testing')) {
         $rules['g-recaptcha-response'] = 'required|captcha';
     }
     return Validator::make($data, $rules);
 }
Ejemplo n.º 10
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $orphanedFor = Carbon::now()->subDays($this->cleanupAfter);
     $orphanUsers = User::where('status', User::STATUS_UNCONFIRMED)->where('created_at', '>', $orphanedFor)->get();
     foreach ($orphanUsers as $user) {
         $user->notify(new AccountDeleted());
         $user->delete();
     }
 }
Ejemplo n.º 11
0
 /**
  * @test
  */
 public function canTransferOwnership()
 {
     $guardian = User::where('email', DatabaseSeeder::GUARDIAN_EMAIL)->firstOrFail();
     $this->assertTrue($guardian->isNotAn(Role::HEAD_COACH));
     $this->assertTrue($this->group->owner->isAn(Role::HEAD_COACH));
     $this->visit('/admin/groups/' . $this->group->id)->click('Transfer Ownership')->see('Transfer Ownership: ' . $this->group->name)->select($guardian->id, 'user_id')->press('Transfer')->see('Ownership has been transferred');
     Bouncer::refresh();
     $this->assertTrue($guardian->isAn(Role::HEAD_COACH));
     $this->assertTrue(Group::findOrFail($this->group->id)->isOwner($guardian));
 }
Ejemplo n.º 12
0
 public function register(Tournament $tournament, array $attributes = null, User $user = null, Group $group = null) : Spectator
 {
     $adult = app(Spectator::class, [['tournament_id' => $tournament->id, 'group_id' => $group == null ? null : $group->id, 'shirt_size' => $attributes['shirt_size']]]);
     if ($user != null) {
         $adult->user_id = $user->id;
     } else {
         // attempt to look up the user by email address
         if (isset($attributes['email'])) {
             $user = User::where('email', $attributes['email'])->first();
             if ($user != null && $user->exists()) {
                 $adult->user_id = $user->id;
             }
         }
         if (isset($attributes['address_one'])) {
             $address = app(Address::class, [['address_one' => $attributes['address_one'], 'address_two' => $attributes['address_two'], 'zip_code' => $attributes['zip_code']]]);
             $address->save();
             $adult->address_id = $address->id;
         }
     }
     // fields are set by head coaches when they register for adults
     if (isset($attributes['first_name'])) {
         $adult->first_name = $attributes['first_name'];
     }
     if (isset($attributes['last_name'])) {
         $adult->last_name = $attributes['last_name'];
     }
     if (isset($attributes['email'])) {
         $adult->email = $attributes['email'];
     }
     if (isset($attributes['gender'])) {
         $adult->gender = $attributes['gender'];
     }
     // spouse data
     if (isset($attributes['spouse_first_name']) && !empty($attributes['spouse_first_name'])) {
         $adult->spouse_first_name = $attributes['spouse_first_name'];
         $adult->spouse_gender = $attributes['spouse_gender'];
         $adult->spouse_shirt_size = $attributes['spouse_shirt_size'];
     }
     $adult->save();
     // attach minors
     if (isset($attributes['minor'])) {
         $minors = [];
         foreach ($attributes['minor'] as $minor) {
             if (strlen($minor['first_name']) > 0) {
                 $minors[] = app(Minor::class, [['name' => $minor['first_name'], 'age' => $minor['age'], 'shirt_size' => $minor['shirt_size'], 'gender' => $minor['gender']]]);
             }
         }
         if (count($minors) > 0) {
             $adult->minors()->saveMany($minors);
         }
     }
     return $adult;
 }
Ejemplo n.º 13
0
 /**
  * @param Request $request
  *
  * @return mixed
  */
 public function update(Request $request, Scrubber $scrubber)
 {
     $user = Auth::user();
     $this->validate($request, User::validationRules($user));
     $user->update(['first_name' => $request->get('first_name'), 'last_name' => $request->get('last_name'), 'email' => $request->get('email'), 'phone' => $scrubber->integer($request->get('phone')), 'gender' => $request->get('gender')]);
     // update user timezone
     $user = Auth::user();
     $settings = $user->settings;
     $settings->setTimezone($request->input('timezone'));
     $user->update(['settings' => $settings]);
     event('user.profile.updated', $user);
     return redirect('/dashboard')->withFlashSuccess('Your changes were saved');
 }
Ejemplo n.º 14
0
 /**
  * This Guardian gains the role of "Guardian" when acceptance tests run.
  */
 private function seedGuardian()
 {
     $addresses = ['Home', 'Work'];
     $testAddresses = [];
     foreach ($addresses as $key => $name) {
         $testAddresses[] = factory(Address::class)->create(['name' => $name, 'latitude' => '38.2515659', 'longitude' => '-85.615241', 'city' => 'Louisville', 'state' => 'KY', 'zip_code' => '40241']);
     }
     $testGuardian = User::create(['status' => User::STATUS_CONFIRMED, 'first_name' => 'Test', 'last_name' => 'Guardian', 'email' => self::GUARDIAN_EMAIL, 'password' => bcrypt(self::GUARDIAN_PASSWORD), 'primary_address_id' => $testAddresses[0]->id]);
     $testGuardian->addresses()->saveMany($testAddresses);
     $playerCreator = App::make(PlayerCreator::class);
     $playerCreator->create($testGuardian, ['first_name' => 'John', 'last_name' => 'Watson', 'gender' => 'M', 'birthday' => '2/24/1988']);
     $testGuardian = User::find($testGuardian->id);
     $playerCreator->create($testGuardian, ['first_name' => 'Emily', 'last_name' => 'Smith', 'gender' => 'F', 'birthday' => '2/24/1986']);
     $playerCreator->create($testGuardian, ['first_name' => 'Alex', 'last_name' => 'Johnson', 'gender' => 'M', 'birthday' => '6/14/1987']);
 }
Ejemplo n.º 15
0
 /**
  * @test
  */
 public function associateWithExistingUserIfEmailAddressMatches()
 {
     $firstName = 'Jane';
     $lastName = 'Lork';
     //allow GUID to be set
     User::unguard();
     User::create(['guid' => md5(uniqid() . microtime()), 'email' => $this->providerUser->getEmail(), 'first_name' => $firstName, 'last_name' => $lastName, 'primary_address_id' => Address::firstOrFail()->id]);
     User::reguard();
     $this->call('GET', '/login/' . ThirdPartyAuthenticator::PROVIDER_GOOGLE, ['code' => uniqid()]);
     // logged in as pre-existing user
     $this->followRedirects()->see($firstName . ' ' . $lastName);
     //assert user was not created
     $name = explode(' ', $this->providerUser->getName());
     $createdUser = User::where('first_name', $name[0])->where('last_name', $name[1])->where('email', $this->providerUser->getEmail())->where('avatar', $this->providerUser->getAvatar())->count() > 0;
     $this->assertFalse($createdUser);
 }
Ejemplo n.º 16
0
 public function register(Tournament $tournament, array $attributes = null, User $user = null, Group $group = null) : TournamentQuizmaster
 {
     $tournamentQuizmaster = app(TournamentQuizmaster::class, [['tournament_id' => $tournament->id, 'group_id' => $group == null ? null : $group->id]]);
     if ($user != null) {
         $tournamentQuizmaster->user_id = $user->id;
     } elseif (isset($attributes['email'])) {
         // attempt to look up the user by email address
         $user = User::where('email', $attributes['email'])->first();
         if ($user != null && $user->exists()) {
             $tournamentQuizmaster->user_id = $user->id;
         }
     }
     // fields are set by head coaches when they register for quizmasters
     if (isset($attributes['first_name'])) {
         $tournamentQuizmaster->first_name = $attributes['first_name'];
     }
     if (isset($attributes['last_name'])) {
         $tournamentQuizmaster->last_name = $attributes['last_name'];
     }
     if (isset($attributes['email'])) {
         $tournamentQuizmaster->email = $attributes['email'];
     }
     if (isset($attributes['gender'])) {
         $tournamentQuizmaster->gender = $attributes['gender'];
     }
     $tournamentQuizmaster->shirt_size = $attributes['shirt_size'];
     /** @var QuizzingPreferences $quizzingPreferences */
     $quizzingPreferences = $tournamentQuizmaster->quizzing_preferences;
     // if we have one, assume we have them all
     $hasQuizzingPreferences = isset($attributes['quizzed_at_tournament']);
     if ($hasQuizzingPreferences) {
         $quizzingPreferences->setQuizzedAtThisTournamentBefore($attributes['quizzed_at_tournament']);
         $quizzingPreferences->setTimesQuizzedAtThisTournament($attributes['times_quizzed_at_tournament']);
         $quizzingPreferences->setGamesQuizzedThisSeason($attributes['games_quizzed_this_season']);
         $quizzingPreferences->setQuizzingInterest($attributes['quizzing_interest']);
     }
     $tournamentQuizmaster->quizzing_preferences = $quizzingPreferences;
     $tournamentQuizmaster->save();
     // if we didn't get preferences, email them for them
     if ($hasQuizzingPreferences == false) {
         Mail::queue('emails.quizmaster-request-quizzing-preferences', ['tournament' => $tournament, 'group' => $group, 'tournamentQuizmaster' => $tournamentQuizmaster], function (Message $message) use($tournament, $tournamentQuizmaster) {
             $message->to($tournamentQuizmaster->email, $tournamentQuizmaster->full_name)->subject($tournament->name . ' Quizzing Preferences');
         });
     }
     return $tournamentQuizmaster;
 }
Ejemplo n.º 17
0
 /**
  * @test
  */
 public function canRegisterANewAccountWithSurvey()
 {
     $email = 'actest' . time() . '@testerson.com';
     $this->visit('/register')->type($email, 'email')->type($this->password, 'password')->type($this->password, 'password_confirmation')->press('Register')->seePageIs('/login')->see('Please follow the link in the confirmation email we just sent you.');
     // skip the email confirmation step
     User::where('email', $email)->update(['status' => User::STATUS_CONFIRMED]);
     $this->login($email, $this->password)->type('Johnson', 'first_name')->type('Johnson', 'last_name')->type('1234567890', 'phone')->type('123 Test Street', 'address_one')->type('Apt 1', 'address_two')->type('40241', 'zip_code');
     $answerId = 4;
     $otherText = uniqid();
     $this->check('answer[1][' . $answerId . ']')->check('answer[1][7]')->type($otherText, 'other[1]')->press('Save')->seePageIs('/dashboard');
     $user = User::where('email', $email)->first();
     $otherAnswer = RegistrationSurveyAnswer::where('question_id', 1)->where('answer', 'Other')->first();
     $userSurvey = $user->surveys->get(2);
     $this->assertEquals($answerId, $user->surveys->first()->answer_id);
     $this->assertEquals($otherAnswer->id, $userSurvey->answer_id);
     $this->assertEquals($otherText, $userSurvey->other);
 }
Ejemplo n.º 18
0
 public function sendUserInvite(UserInviteRequest $request)
 {
     $group = Group::findOrFail($request->route('group'));
     $user = User::where('email', $request->get('email'))->first();
     DB::beginTransaction();
     $recipientName = null;
     if (is_null($user)) {
         $recipientEmail = $request->get('email');
     } else {
         $recipientEmail = $user->email;
         $recipientName = $user->full_name;
     }
     $invitation = Invitation::create(['type' => Invitation::TYPE_MANAGE_GROUP, 'email' => is_null($user) ? $request->get('email') : null, 'user_id' => is_null($user) ? null : $user->id, 'inviter_id' => Auth::user()->id, 'group_id' => $group->id]);
     Mail::queue('emails.group-user-invitation', ['invitation' => $invitation, 'header' => 'Group Management Invitation', 'invitationText' => '<strong>' . Auth::user()->full_name . '</strong> has invited you to help manage the ' . $group->program->abbreviation . ' <strong>' . $group->name . '</strong> group.'], function (Message $message) use($recipientEmail, $recipientName) {
         $message->to($recipientEmail, $recipientName)->subject('Bible Bowl Group Management Invitation');
     });
     DB::commit();
     return redirect('/group/' . $group->id . '/settings/users')->withFlashSuccess('Invitation has been sent');
 }
Ejemplo n.º 19
0
 /**
  * Find the existing user or create a new one for this account.
  *
  * @param $provider
  *
  * @throws EmailAlreadyInUse
  *
  * @return User
  */
 public function findOrCreateUser($provider) : User
 {
     /** @var \Laravel\Socialite\Two\User $providerUser */
     $providerUser = $this->socialite->driver($provider)->user();
     $user = User::byProvider($provider, $providerUser->id)->first();
     if (is_null($user)) {
         $user = User::where('email', $providerUser->getEmail())->first();
         // If provider isn't associated with user, do that now
         if (is_null($user)) {
             return $this->registrar->create($provider, $providerUser);
         }
         $userProvider = app(UserProvider::class, [['provider' => $provider, 'provider_id' => $providerUser->getId()]]);
         $user->providers()->save($userProvider);
         return $user;
     }
     // update the avatar if it has changed
     if (!is_null($providerUser->getAvatar()) && $user->avatar != $providerUser->getAvatar()) {
         $user->update(['avatar' => $providerUser->getAvatar()]);
     }
     return $user;
 }
Ejemplo n.º 20
0
 /**
  * @return mixed
  */
 public function postSetup(Request $request, Scrubber $scrubber)
 {
     $request->merge(['name' => 'Home', 'phone' => $scrubber->integer($request->get('phone'))]);
     $userRules = array_only(User::validationRules(), ['gender', 'phone', 'first_name', 'last_name']);
     $this->validate($request, array_merge(Address::validationRules(), $userRules), Address::validationMessages());
     //update the info
     DB::transaction(function () use($request) {
         $user = Auth::user();
         $user->first_name = $request->get('first_name');
         $user->last_name = $request->get('last_name');
         $user->phone = $request->get('phone');
         $user->gender = $request->get('gender');
         $user->save();
         // set timezone
         $settings = $user->settings;
         $settings->setTimezone($request->input('timezone'));
         $user->update(['settings' => $settings]);
         // add user address
         $address = App::make(Address::class, [$request->except(['first_name', 'last_name', 'phone', 'gender', 'timezone', 'answer', 'other'])]);
         $user->addresses()->save($address);
         $user->update(['primary_address_id' => $address->id]);
         // record survey
         if ($request->has('answer') && count($request->get('answer')) > 0) {
             $surveys = [];
             foreach ($request->get('answer') as $questionId => $answers) {
                 foreach ($answers as $answerId => $true) {
                     $surveys[] = app(RegistrationSurvey::class, [['answer_id' => $answerId]]);
                 }
                 // update that question's "Other"
                 if ($request->has('other.' . $questionId) && strlen($request->get('other')[$questionId]) > 0) {
                     $otherAnswer = RegistrationSurveyAnswer::where('question_id', $questionId)->where('answer', 'Other')->first();
                     $surveys[] = app(RegistrationSurvey::class, [['answer_id' => $otherAnswer->id, 'other' => $request->get('other')[$questionId]]]);
                 }
             }
             $user->surveys()->saveMany($surveys);
         }
     });
     return redirect('/dashboard');
 }
Ejemplo n.º 21
0
 private function seedTournament($director)
 {
     $tournamentName = 'My Test Tournament';
     $tournament = Tournament::create(['program_id' => Program::TEEN, 'slug' => $this->season->name . ' ' . $tournamentName, 'season_id' => $this->season->id, 'name' => $tournamentName, 'start' => Carbon::now()->addMonths(5)->format('m/d/Y'), 'end' => Carbon::now()->addMonths(7)->format('m/d/Y'), 'registration_start' => Carbon::now()->subMonths(3)->format('m/d/Y'), 'registration_end' => Carbon::now()->addDays(4)->format('m/d/Y'), 'creator_id' => $director->id, 'details' => '<h3>Nearby Hotels</h3><p>There are a few nearby:</p><ul><li>Option #1</li></ul>', 'max_teams' => 64, 'lock_teams' => Carbon::now()->addMonths(3)->addWeeks(2)->format('m/d/Y'), 'earlybird_ends' => Carbon::now()->addMonths(3)->format('m/d/Y')]);
     $tournament->events()->create(['event_type_id' => EventType::ROUND_ROBIN, 'price_per_participant' => '25.00']);
     $tournament->events()->create(['event_type_id' => EventType::DOUBLE_ELIMINATION, 'price_per_participant' => '35.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::PLAYER, 'requires_registration' => 1, 'fee' => '15.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::TEAM, 'requires_registration' => 1, 'earlybird_fee' => '50.00', 'fee' => '75.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::QUIZMASTER, 'requires_registration' => 1, 'fee' => '30.00', 'onsite_fee' => '40.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::ADULT, 'requires_registration' => 1, 'fee' => '30.00', 'onsite_fee' => '40.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::FAMILY, 'requires_registration' => 1, 'fee' => '60.00', 'onsite_fee' => '75.00']);
     $groupId = 2;
     $tournament->tournamentQuizmasters()->create(['group_id' => $groupId, 'first_name' => 'Keith', 'last_name' => 'Webb', 'email' => '*****@*****.**', 'gender' => 'M']);
     $user = User::where('email', self::QUIZMASTER_EMAIL)->first();
     $receipt = $this->seedReceipt($user);
     $tournament->tournamentQuizmasters()->create(['group_id' => $groupId, 'receipt_id' => $receipt->id, 'first_name' => 'Warner', 'last_name' => 'Jackson', 'email' => '*****@*****.**', 'gender' => 'F']);
     // guest spectators
     $director = User::where('email', self::DIRECTOR_EMAIL)->first();
     $tournament->spectators()->create(['group_id' => $groupId, 'receipt_id' => $receipt->id, 'first_name' => 'Sarah', 'last_name' => 'Jones', 'shirt_size' => 'L', 'email' => '*****@*****.**', 'gender' => 'F', 'address_id' => $director->primary_address_id]);
     $tournament->spectators()->create(['group_id' => $groupId, 'first_name' => 'Jonathan', 'last_name' => 'Wicker', 'shirt_size' => 'L', 'email' => '*****@*****.**', 'gender' => 'M', 'address_id' => $director->primary_address_id]);
     // family spectators
     $tournament->spectators()->create(['group_id' => $groupId, 'user_id' => $director->id, 'receipt_id' => $receipt->id, 'spouse_first_name' => 'Michelle', 'spouse_gender' => 'F', 'spouse_shirt_size' => 'M']);
     $spectator = $tournament->spectators()->create(['group_id' => $groupId, 'first_name' => 'Clark', 'last_name' => 'Larkson', 'shirt_size' => 'XL', 'email' => '*****@*****.**', 'gender' => 'M', 'spouse_first_name' => 'Lucy', 'spouse_gender' => 'F', 'spouse_shirt_size' => 'M']);
     $spectator->minors()->create(['name' => 'Jonathan', 'age' => '6', 'shirt_size' => 'YS', 'gender' => 'M']);
     $spectator->minors()->create(['name' => 'Christine', 'age' => '12', 'shirt_size' => 'YM', 'gender' => 'F']);
 }
Ejemplo n.º 22
0
 /**
  * Landing page for a user confirming their email addres.
  *
  * @param string $guid
  *
  * @return mixed
  */
 public function getConfirm($guid)
 {
     User::where('guid', $guid)->update(['status' => User::STATUS_CONFIRMED]);
     return redirect()->back()->withFlashSuccess('Your email address has been confirmed, you may now login');
 }
Ejemplo n.º 23
0
 public function adminUser()
 {
     return User::findOrFail($this->get(self::ADMIN_USER));
 }
Ejemplo n.º 24
0
 public function setupAsDirector()
 {
     $this->director = User::where('email', DatabaseSeeder::DIRECTOR_EMAIL)->first();
     $this->season = Season::orderBy('id', 'DESC')->first();
     $this->actingAs($this->director)->withSession([SessionManager::SEASON => $this->season->toArray()]);
 }
Ejemplo n.º 25
0
 /**
  * Allow the admin to switch users.
  *
  * @param $userId
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function switchUser($userId)
 {
     $user = User::findOrFail($userId);
     Session::switchUser($user);
     return redirect('dashboard')->withFlashSuccess("You're now logged in as " . $user->full_name . ', use the bar at the bottom to switch back');
 }
Ejemplo n.º 26
0
 private function seedKeithGuardian()
 {
     $faker = Factory::create();
     $addresses = ['Home', 'Work', 'Church'];
     $savedAddresses = [];
     foreach ($addresses as $key => $name) {
         $savedAddresses[] = factory(Address::class)->create(['name' => $name]);
     }
     $guardian = User::create(['status' => User::STATUS_CONFIRMED, 'first_name' => 'Keith', 'last_name' => 'Guardian', 'email' => '*****@*****.**', 'password' => bcrypt('biblebowl'), 'primary_address_id' => $savedAddresses[0]->id]);
     $guardian->addresses()->saveMany($savedAddresses);
     // Generate fake player information.
     $num_players = 5;
     for ($i = 0; $i < $num_players; $i++) {
         $guardian = User::find($guardian->id);
         $playerCreator = App::make(PlayerCreator::class);
         $playerCreator->create($guardian, ['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'gender' => rand(0, 1) ? 'M' : 'F', 'birthday' => $faker->dateTimeBetween('-18 years', '-9 years')->format('m/d/Y')]);
     }
 }
Ejemplo n.º 27
0
 public function setupAsGuardian()
 {
     $this->guardian = User::where('email', DatabaseSeeder::GUARDIAN_EMAIL)->first();
     $this->season = Season::orderBy('id', 'DESC')->first();
     $this->actingAs($this->guardian)->withSession([SessionManager::SEASON => $this->season->toArray()]);
 }
Ejemplo n.º 28
0
 public function setupAsQuizmaster()
 {
     $this->quizmaster = User::where('email', DatabaseSeeder::QUIZMASTER_EMAIL)->first();
     $this->actingAs($this->quizmaster);
 }
Ejemplo n.º 29
0
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(User::class, function (Generator $faker) {
    return ['status' => User::STATUS_CONFIRMED, 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $faker->email, 'phone' => $faker->phoneNumber, 'password' => str_random(10), 'remember_token' => str_random(10)];
});
$factory->define(Player::class, function (Generator $faker) {
    return ['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'gender' => rand(0, 1) ? 'M' : 'F', 'birthday' => $faker->dateTimeBetween('-18 years', '-9 years')->format('m/d/Y')];
});
$factory->define(Address::class, function (Generator $faker) {
    return ['name' => 'Home', 'address_one' => $faker->buildingNumber . ' ' . $faker->streetName . ' ' . $faker->streetSuffix, 'address_two' => rand(0, 5) ? $faker->secondaryAddress : null, 'latitude' => $faker->latitude, 'longitude' => $faker->longitude, 'city' => $faker->city, 'state' => $faker->stateAbbr, 'zip_code' => $faker->postcode];
});
$factory->define(Tournament::class, function (Generator $faker) {
    return ['name' => $faker->word, 'program_id' => Program::TEEN, 'season_id' => Season::current()->id, 'start' => Carbon::now()->addMonth(1), 'end' => Carbon::now()->addDays(14), 'registration_start' => Carbon::now()->subMonth(1), 'registration_end' => Carbon::now()->subDays(14), 'creator_id' => User::where('email', DatabaseSeeder::DIRECTOR_EMAIL)->first()->id];
});
/**
 * @return User
 */
function seedGuardian($attrs = [], $addressAttrs = [])
{
    $address = factory(Address::class)->create($addressAttrs);
    $attrs['primary_address_id'] = $address->id;
    $user = factory(User::class)->create($attrs);
    $address->user_id = $user->id;
    $address->save();
    $role = Role::where('name', Role::GUARDIAN)->firstOrFail();
    $user->assign($role);
    return $user;
}
Ejemplo n.º 30
0
 public function removeHeadCoach(User $user)
 {
     $user->groups()->detach($this->id);
     if ($user->groups()->count() == 0) {
         $role = Role::where('name', Role::HEAD_COACH)->firstOrFail();
         $user->retract($role);
     }
 }