Exemplo n.º 1
0
 public function run()
 {
     $model = new \frontend\widgets\rating\models\Rating();
     $model->nid = $this->nid;
     $model->model = $this->model;
     $model->return_id = $this->return_id;
     if (!$model->isRated()) {
         return '';
     }
     $model->loadData($this->data);
     return $this->render('rate', ['model' => $model, 'data' => $this->data]);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (Yii::$app->request->isPost) {
         $model = new \frontend\widgets\rating\models\Rating();
         $post = Yii::$app->request->post();
         if ($model->load($post) && $model->save()) {
             if (Yii::$app->request->isAjax) {
                 Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
                 return $model->return;
             }
             return Yii::$app->response->redirect(Yii::$app->request->referrer);
         }
     } else {
         exit;
     }
     //$this->redirect('/', 302);
 }