Beispiel #1
0
 /**
  * Finds the Job model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $_id
  * @return Job the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Job::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionReset()
 {
     if (Yii::$app->user->can('updateResource')) {
         $model = Job::findOne(['id' => Yii::$app->request->get('id')]);
         if ($model->reset()) {
             $model->save();
             Yii::$app->getSession()->setFlash('success', 'Job reset.');
         } else {
             Yii::$app->getSession()->setFlash('error', 'Failed to reset job.');
         }
     } else {
         Yii::$app->getSession()->setFlash('error', 'Not allowed.');
     }
     return $this->redirect(['index']);
 }