Пример #1
0
 public function actionUp($type, $id)
 {
     $ret_val = false;
     $existing = new Rating();
     $existing->queryOptions['user_id'] = \Yii::$app->user->getId();
     $existing->queryOptions['remote_type'] = $type;
     $existing->queryOptions['remote_id'] = $id;
     switch ($existing->exists()) {
         case false:
             $model = new Rating(['remote_type' => $type, 'remote_id' => $id]);
             $model->save();
             break;
         default:
             $existing = new Rating();
             $existing->queryOptions['remote_type'] = $type;
             $existing->queryOptions['remote_id'] = $id;
             $count = $existing->getCount();
             switch (1) {
                 case $count < Users::find()->count():
                     $ret_val = true;
                     break;
             }
             break;
     }
     $this->renderResponse($ret_val);
 }
Пример #2
0
 public function run()
 {
     $r = new RatingModel(['parent_id' => $this->parentId, 'parent_type' => $this->parentType]);
     $rating = '';
     switch (\nitm\widgets\models\User::isAdmin()) {
         case true:
             break;
     }
     $rating .= Html::tag('div', Html::tag('strong', $r->rating($this->model), ['id' => 'rating-value' . $this->model->getUnique()]) . "%", ['class' => 'center-block text-center']);
     $rating .= $this->getActions();
     $this->options['id'] .= $this->parentId;
     echo Html::tag('div', $rating, $this->options);
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRatingModel()
 {
     return $this->getWidgetRelationModelQuery(\nitm\widgets\models\Rating::className());
 }