protected function isEventActive($shift_id) { if (($model = Shift::findOne($shift_id)) !== null) { return $model->team->event->active; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function addUser() { if (!$this->validate()) { return false; } if (Shift::findOne($this->shift_id === null) || User::findOne($this->user_id == null)) { throw new NotFoundHttpException('The requested page does not exist.'); } $participant = new Participant(); $participant->shift_id = $this->shift_id; $participant->user_id = $this->user_id; return $participant->save(); }
/** * Finds the Shift model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Shift the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Shift::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }