/**
  * @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);
 }
 public function claim($guid, $action)
 {
     $invitation = Invitation::where('guid', $guid)->firstOrFail();
     if ($invitation->status != Invitation::SENT) {
         return $this->redirectRoute()->withFlashInfo('This invitation has expired or has already been claimed');
     }
     if ($action == 'accept') {
         Session::setPendingInvitation($invitation);
         return $this->redirectRoute()->withFlashSuccess('Login to accept this invitation');
     } else {
         $invitation->update(['status' => Invitation::DECLINED]);
         return $this->redirectRoute()->withFlashSuccess('Invitation has been declined');
     }
 }
Exemple #3
0
 /**
  * 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 retractInvite(RetractUserInviteRequest $request, $groupId, $invitationId)
 {
     Invitation::where('id', $invitationId)->delete();
     return redirect('/group/' . $request->route('group') . '/settings/users')->withFlashSuccess('Invitation has been retracted');
 }