public function groupStats(Season $season)
 {
     return ['byProgram' => Group::whereHas('players', function (Builder $q) use($season) {
         $q->where('player_season.season_id', $season->id)->whereNull('player_season.inactive');
     })->with('program')->select('groups.program_id', DB::raw('count(groups.id) as total'))->groupBy('groups.program_id')->get(), 'byType' => Group::whereHas('players', function (Builder $q) use($season) {
         $q->where('player_season.season_id', $season->id)->whereNull('player_season.inactive');
     })->with('type')->select('groups.group_type_id', DB::raw('count(groups.id) as total'))->groupBy('groups.group_type_id')->get()];
 }
Example #2
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return Group::whereHas('users', function (Builder $q) {
         $q->where('id', Auth::user()->id);
     })->where('id', $this->route('group'))->count() > 0;
 }