Esempio 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()]);
 }
Esempio n. 2
0
 /**
  * @return \Illuminate\View\View
  */
 public function searchBeforeCreate()
 {
     $groups = [];
     if ($hasSearched = Input::has('q')) {
         $groups = Group::where('name', 'LIKE', '%' . Input::get('q') . '%')->with('meetingAddress', 'program')->orderBy('name', 'ASC')->get();
     }
     return view('/group/create-search', ['groups' => $groups, 'hasSearched' => $hasSearched]);
 }
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $groupId = $this->route('group');
     if (Auth::user()->isA(Role::HEAD_COACH)) {
         $groupId = Session::group()->id;
     }
     return Group::where('id', $groupId)->where('owner_id', Auth::id())->exists();
 }
 /**
  * @test
  */
 public function canRegisterPlayersForAllPrograms()
 {
     $nearbyGroup = Group::where('name', DatabaseSeeder::GROUP_NAME)->firstOrFail();
     $this->visit('/register/players')->see('David Webb')->see('Ethan Smith')->select('11', 'player[1][grade]')->select('10', 'player[2][grade]')->press('Continue')->dontSee('Submit Registration')->click('Join Beginner Group')->type('Southeast', 'q')->press('Search')->click('Register Later')->seePageIs('/register/summary')->see('Your Beginner players have been removed from this registration')->dontSee('Beginner Bible Bowl');
     // verify beginner players have been removed
     $beginner = Program::findOrFail(Program::BEGINNER);
     /** @var \BibleBowl\Seasons\GroupRegistration $registration */
     $registration = Session::seasonalGroupRegistration();
     $this->assertEquals(0, $registration->numberOfPlayers($beginner));
     $this->click('Join Teen Group')->click('#select-nearby-group-' . $nearbyGroup->id)->seePageIs('/register/summary')->see($nearbyGroup->name)->press('Submit Registration')->see('You must agree to the Terms of Participation')->check('terms_of_participation')->press('Submit Registration')->see('Your registration has been submitted!')->visit('/register/players')->dontSee('David Webb')->dontSee('Ethan Smith');
 }
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     if (Auth::user()->isNotA(Role::HEAD_COACH)) {
         return false;
     }
     $groupId = $this->route('group');
     if ($groupId == null) {
         $groupId = Session::group()->id;
     }
     return Group::where('id', $groupId)->whereHas('users', function (Builder $q) {
         $q->where('users.id', Auth::user()->id);
     })->exists();
 }
Esempio n. 6
0
 /**
  * @return Group|null
  */
 public function getGroupToRegisterWith()
 {
     return Group::where('guid', $this->get(self::REGISTER_WITH_GROUP))->first();
 }
Esempio n. 7
0
 public function setUp()
 {
     parent::setUp();
     $this->setupAsDirector();
     $this->group = Group::where('name', DatabaseSeeder::GROUP_NAME)->first();
 }
Esempio n. 8
0
 public static function validationRules($groupAlreadyExists = false)
 {
     // Check to see if a group is a duplicate by looking at the location where they meet (zip code or city/state
     // and their program/name when the group is created
     Validator::extend('isnt_duplicate', function ($attribute, $value, $parameters, $validator) {
         $meetingAddress = Address::findOrFail($validator->getData()['meeting_address_id']);
         $group = Group::where('name', $value)->where('program_id', $validator->getData()['program_id'])->whereHas('meetingAddress', function ($query) use($meetingAddress) {
             $query->orWhere(function ($query) use($meetingAddress) {
                 $query->where('city', '=', $meetingAddress->city);
                 $query->where('state', '=', $meetingAddress->state);
             })->where('zip_code', '=', $meetingAddress->zip_code);
         })->first();
         return is_null($group);
     });
     return ['name' => 'required|max:128' . ($groupAlreadyExists ? '' : '|isnt_duplicate'), 'program_id' => 'required', 'owner_id' => 'required|exists:users,id', 'address_id' => 'required|exists:addresses,id'];
 }
 public static function viewBindings()
 {
     \View::creator('seasons.registration.partials.group-search', function (View $view) {
         $searchResults = null;
         if (Input::has('q')) {
             $searchResults = Group::where('program_id', $view->getData()['program']->id)->active()->where('name', 'LIKE', '%' . Input::get('q') . '%')->get();
         }
         $view->with('searchResults', $searchResults);
     });
     \View::creator('seasons.registration.register_form', function (View $view) {
         $view->with('players', Auth::user()->players()->notRegisteredWithNBB(Session::season(), Auth::user())->get());
     });
 }
Esempio n. 10
0
 public function index()
 {
     $groups = Group::where('name', 'LIKE', '%' . Input::get('q') . '%')->with('owner', 'program')->orderBy('name', 'ASC')->paginate(25);
     return view('admin.groups.index', ['groups' => $groups->appends(Input::only('q'))]);
 }