Пример #1
0
 /**
  * Creates a new Search model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Search();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index', 'viewer_id' => $model->viewer_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 /**
  * @param Search $search
  * @param int    $status
  */
 protected function finish($search, $status)
 {
     $search->finished_at = Carbon::now()->toDateTimeString();
     switch ($status) {
         case static::FINISH_STATUS_SUCCESSFUL:
             $search->success = 1;
             break;
         case static::FINISH_STATUS_TIMEOUT:
             $search->timeout = 1;
             break;
         case static::FINISH_STATUS_NOT_SUCCESSFUL:
             break;
         case static::FINISH_STATUS_STOPPED:
             $search->stopped = 1;
             break;
         default:
     }
     // Flush dell'ultimo fetch
     $search->flushLastFetch();
     // Salvo la ricerca
     $search->save();
 }