/** * @test */ public function canAcceptGroupInvitations() { $group = Group::active()->firstOrFail(); $invitation = Invitation::create(['type' => Invitation::TYPE_MANAGE_GROUP, 'inviter_id' => $group->owner_id, 'group_id' => $group->id]); $this->setupAsDirector(); $this->visit('/invitation/' . $invitation->guid . '/accept')->followRedirects()->see('Invitation has been accepted')->assertSessionHas(\BibleBowl\Users\Auth\SessionManager::GROUP, $invitation->group->toArray()); $invitation = Invitation::findOrFail($invitation->id); $this->assertEquals(Invitation::ACCEPTED, $invitation->status); }
/** * Run the database seeds. * * @return void */ public function run() { $this->faker = Factory::create(); // load ModelFactory.php so functions can be used later factory(User::class); Season::create(['name' => date('Y') - 1 . '-' . date('y')]); $this->call('ProductionSeeder'); self::$isSeeding = true; $this->season = Season::orderBy('id', 'DESC')->first(); $director = $this->seedAdmin(); $this->seedGuardian(); $this->seedQuizmaster(); $headCoach = $this->seedHeadCoach(); $this->call('AcceptanceTestingSeeder'); if (app()->environment('staging')) { $this->call('StagingSeeder'); } $this->seedTournament($director); Invitation::create(['type' => Invitation::TYPE_MANAGE_GROUP, 'email' => null, 'user_id' => $director->id, 'inviter_id' => $headCoach->id, 'group_id' => 2]); self::$isSeeding = false; }
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'); }