コード例 #1
0
ファイル: ParticipantController.php プロジェクト: ninetor/23
 /**
  * Finds the Participant model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Participant the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Participant::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionDelete($shift_id, $user_id)
 {
     if (!$this->isEventActive($shift_id)) {
         Yii::$app->session->addFlash("error", "Closed events cannot be modified.");
         return $this->goBack();
     }
     $model = Participant::findOne(['shift_id' => $shift_id, 'user_id' => $user_id])->delete();
     return $this->redirect(['/shift/view', 'id' => $shift_id]);
 }