/** * Update season. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $season_id) { $season = Season::find($season_id); $season->fill($request->except(['number_of_teams'])); $season->save(); return response()->json(['success' => true]); }
public function actionCreateseason($id = null) { if ($id != null) { $t = T::findOne(['id' => $id]); if ($t != null and $t['admin_id'] == Yii::$app->user->id) { $season = new Season(); if ($season->load(Yii::$app->request->post())) { $season->time_update = time(); $season->time = time(); $season->t_id = $id; if (trim($season->name) == null) { $season->name = 'Season 1'; } $season->admin_id = Yii::$app->user->id; if ($season->save()) { return $this->render('view', ['t' => $t, 'seasons' => Season::find()->where(['t_id' => $id])->all(), 'msgs' => Msgs::find()->where(['unit_type' => 1, 'unit_id' => $t['id']])->orderBy('id DESC')->limit(50)->all()]); } else { echo 'Ошибка сохранения!!!'; } } return $this->render('createseason', ['season' => $season, 't' => $t]); } else { echo 'Ошибка! Не найден турнир или Вы не админ тунира...'; } } else { echo 'Ошибка! Не получены данные...'; } }
/** * Remove the specified resource from storage. * * @param int $id * * @return mixed */ public function destroy($id) { $canBeDeleted = empty(Season::find($id)->divisions->toArray()); if ($canBeDeleted) { Season::destroy($id); \Flash::success('Season deleted!'); } else { \Flash::error('Cannot delete because they are existing divisions in this season.'); } return redirect('admin/data-management/seasons'); }