Ejemplo n.º 1
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.º 2
0
 /**
  * @return \Illuminate\View\View
  */
 public function getRegistrationSurveys(Request $request, SurveyMetricsRepository $metrics)
 {
     $seasons = Season::orderBy('id', 'DESC')->get();
     $currentSeason = $request->has('seasonId') ? Season::findOrFail($request->get('seasonId')) : $seasons->first();
     $questions = [];
     foreach (RegistrationSurveyQuestion::orderBy('order')->get() as $question) {
         $questions[$question->id] = ['question' => $question, 'metrics' => $metrics->byQuestion($question, $currentSeason)];
     }
     return view('admin.reports.registration-surveys', ['currentSeason' => $currentSeason, 'seasons' => $seasons, 'questions' => $questions]);
 }
Ejemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $this->season = Season::orderBy('id', 'DESC')->first();
     $this->updateMailchimpIds();
     $this->seedJosiahDirector();
     $this->seedJosiahGuardian();
     $this->seedJosiahHeadCoach();
     $this->seedKeithBoardMember();
     $this->seedKeithGuardian();
     $this->seedKeithHeadCoach();
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(AutomatedGroupDeactivator $groupDeactivator)
 {
     /** @var Carbon $endDate */
     $endDate = Setting::seasonEnd();
     /** @var Carbon $startDate */
     $startDate = Setting::seasonStart();
     $nextSeasonName = $startDate->format('Y-') . $startDate->addYear()->format('y');
     // notify the office before the season rotates
     $rotateInDays = 7;
     if ($endDate->isBirthday(Carbon::now()->addDays($rotateInDays))) {
         Mail::queue('emails.season-rotate-notification', ['willRotateOn' => $endDate->toFormattedDateString(), 'nextSeasonName' => $nextSeasonName, 'programs' => Program::orderBy('name', 'ASC')->get()], function (Message $message) use($nextSeasonName, $rotateInDays) {
             $message->to(config('biblebowl.officeEmail'))->subject('The ' . $nextSeasonName . ' season begins in ' . $rotateInDays . ' days');
         });
     }
     // rotate the season
     if ($endDate->isBirthday()) {
         /* @var Season $season */
         Season::firstOrCreate(['name' => $nextSeasonName]);
         // since the season rotated today, deactivate inactive groups from last season
         $lastSeason = Season::orderBy('id', 'DESC')->skip(1)->first();
         $groupDeactivator->deactivateInactiveGroups($lastSeason);
     }
 }
Ejemplo n.º 6
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.º 7
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.º 8
0
 public function historicalPlayerSummaryByProgram()
 {
     return Season::orderBy('seasons.created_at', 'DESC')->addSelect('seasons.*', DB::raw('(SELECT COUNT(player_id) FROM player_season INNER JOIN `groups` ON (`groups`.id = player_season.group_id AND `groups`.program_id = ' . Program::BEGINNER . ') WHERE season_id = seasons.id AND player_season.inactive IS NULL) as beginner_count'), DB::raw('(SELECT COUNT(player_id) FROM player_season INNER JOIN `groups` ON (`groups`.id = player_season.group_id AND `groups`.program_id = ' . Program::BEGINNER . ') WHERE season_id = seasons.id AND player_season.inactive IS NOT NULL) as beginner_quitters_count'), DB::raw('(SELECT COUNT(player_id) FROM player_season INNER JOIN `groups` ON (`groups`.id = player_season.group_id AND `groups`.program_id = ' . Program::TEEN . ') WHERE season_id = seasons.id AND player_season.inactive IS NULL) as teen_count'), DB::raw('(SELECT COUNT(player_id) FROM player_season INNER JOIN `groups` ON (`groups`.id = player_season.group_id AND `groups`.program_id = ' . Program::TEEN . ') WHERE season_id = seasons.id AND player_season.inactive IS NOT NULL) as teen_quitters_count'))->limit(5)->get();
 }