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'); }
/** * @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)); }
/** * @test */ public function editIntegrationSettings() { $apiKey = md5(time()) . '-us1'; $listId = '34adf2345wd'; $this->visit('/group/' . $this->group()->id . '/settings/integrations')->check('mailchimp-enabled')->type($apiKey, 'mailchimp-key')->type($listId, 'mailchimp-list-id')->press('Save')->see('Your integration settings have been saved'); $group = Group::findOrFail($this->group()->id); $this->assertTrue($group->settings->mailchimpEnabled()); $this->assertEquals($apiKey, $group->settings->mailchimpKey()); $this->assertEquals($listId, $group->settings->mailchimpListId()); }
/** * @test */ public function canReorderPlayers() { $group = Group::findOrFail(2); $this->withSession([SessionManager::GROUP => $group->toArray()]); $teamSet = TeamSet::findOrFail(1); $team = $teamSet->teams->get(2); $startingPlayerOrder = [$team->players->first()->id, $team->players->get(1)->id]; $this->post('/teams/' . $team->id . '/updateOrder', ['sortOrder' => [$startingPlayerOrder[1], $startingPlayerOrder[0]]])->assertResponseOk(); $team = Team::findOrFail($team->id); $this->assertEquals($startingPlayerOrder[1], $team->players->first()->id); $this->assertEquals($startingPlayerOrder[0], $team->players->get(1)->id); }
/** * Standalone registration is a Spectator that is registering * themselves, not the Head Coach registering on their behalf. */ public function postStandaloneRegistration(StandaloneSpectatorRegistrationRequest $request, $slug, SpectatorRegistrationPaymentReceived $spectatorRegistrationPaymentReceived, SpectatorRegistrar $spectatorRegistrar) { $tournament = Tournament::where('slug', $slug)->firstOrFail(); $spectator = $spectatorRegistrar->register($tournament, $request->except('_token'), Auth::user(), $request->get('group_id') ? Group::findOrFail($request->get('group_id')) : null); $spectatorRegistrationPaymentReceived->setSpectator($spectator); // registrations with fees go to the cart $fee = $tournament->fee($spectator->participant_type); if ($fee > 0) { $cart = Cart::clear(); $cart->setPostPurchaseEvent($spectatorRegistrationPaymentReceived)->save(); $cart->add($spectator->sku(), $fee, 1); return redirect('/cart'); } return $spectatorRegistrationPaymentReceived->successStep(); }
/** * Standalone registration is a Quizmaster that is registering * themselves, not the Head Coach registering on their behalf. */ public function postStandaloneRegistration(StandaloneQuizmasterRegistrationRequest $request, $slug, QuizmasterRegistrationPaymentReceived $quizmasterRegistrationPaymentReceived, QuizmasterRegistrar $quizmasterRegistrar) { $tournament = Tournament::where('slug', $slug)->firstOrFail(); $participantType = ParticipantType::findOrFail(ParticipantType::QUIZMASTER); $tournamentQuizmaster = $quizmasterRegistrar->register($tournament, $request->except('_token'), Auth::user(), $request->get('group_id') ? Group::findOrFail($request->get('group_id')) : null); $quizmasterRegistrationPaymentReceived->setTournamentQuizmaster($tournamentQuizmaster); // registrations with fees go to the cart $fee = $tournament->fee($participantType); if ($fee > 0) { $cart = Cart::clear(); $cart->setPostPurchaseEvent($quizmasterRegistrationPaymentReceived)->save(); $cart->add(TournamentQuizmaster::REGISTRATION_SKU, $fee, 1); return redirect('/cart'); } return $quizmasterRegistrationPaymentReceived->successStep(); }
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'); }
@extends('emails.simple') @section('body') <?php // Serialized objects need to be re-instantiated in order // to have a successful database connection $group = \BibleBowl\Group::findOrFail($groupId); $season = \BibleBowl\Season::current()->first(); $players = $group->players()->pendingRegistrationPayment($season)->get(); $bulletedList = ''; foreach ($players as $player) { $bulletedList .= '<li>' . $player->full_name . '</li>'; } ?> @include('emails.theme.header', [ 'header' => 'Registration Fee Reminder' ]) @include('emails.theme.text-block', [ 'body' => '<p><strong>'.$group->name.'</strong> has <strong>'.count($players).'</strong> player(s) with outstanding '.$group->program->name.' registration fees. Please '.EmailTemplate::link(url('/'), 'login to your Bible Bowl account').' and click "Pay Now" to pay their fees.</p>' ]) @include('emails.theme.text-block', [ 'body' => '<p>Players are more than welcome to try out Bible Bowl for a brief period. If they try it out and decide not to play, please login and mark them as "Inactive" in your '.EmailTemplate::link(url('/roster'), 'player roster').' to avoid future emails.</p>' ]) @include('emails.theme.text-block', [ 'body' => "<p>Here's a list of players with outstanding fees:</p><ul>".$bulletedList.'</ul>' ]) @endsection
/** * @param Program $program * * @return Group */ public function group(Program $program) { return Group::findOrFail($this->attributes['groups'][$program->id]); }
/** * Swap the current user's group for another. * * @param GroupCreatorOnlyRequest $request * @param $id * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function swap(GroupHeadCoachOnlyRequest $request, $id) { Session::setGroup(Group::findOrFail($id)); return redirect('/dashboard'); }
/** * @return \Illuminate\View\View */ public function chooseGroup($programSlug, $groupId) { /** @var GroupRegistration $registration */ $registration = Session::seasonalGroupRegistration(); $registration->addGroup(Group::findOrFail($groupId)); Session::setSeasonalGroupRegistration($registration); return redirect('/register/summary'); }