/** * @param SettingsUpdateRequest $request * * @return mixed */ public function update(SettingsUpdateRequest $request) { DB::transaction(function () use($request) { Setting::setSeasonEnd(Carbon::createFromTimestamp(strtotime($request->get('season_end')))); Setting::save(); // update programs foreach ($request->get('program') as $programId => $toUpdate) { Program::where('id', $programId)->update($toUpdate); } }); return redirect('/admin/settings/')->withFlashSuccess('Your changes were saved'); }
/** * Build a user friendly display name based * on the SKU. * * @return string */ public function name() { // seasonal registrations $seasonalGroupRegistrationPrefix = 'SEASON_REG_'; if (starts_with($this->sku, $seasonalGroupRegistrationPrefix)) { $program = Program::where('slug', str_replace($seasonalGroupRegistrationPrefix, '', $this->sku))->firstOrFail(); return $program->name . ' Seasonal Registration'; } // tournament registrations $tournamentRegistrationPrefix = 'TOURNAMENT_REG_'; if (starts_with($this->sku, $tournamentRegistrationPrefix)) { $pieces = explode('_', $this->sku); unset($pieces[0]); unset($pieces[1]); return ucwords(strtolower(implode(' ', $pieces))) . ' Tournament Registration'; } return $this->sku; }
/** * Query groups by beginner or teen. */ public function scopeByProgram(Builder $query, $program) { if (is_string($program)) { $program = Program::where('slug', $program)->first()->id; } return $query->where('groups.program_id', $program); }