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); }
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); }
/** * @return \yii\db\ActiveQuery */ public function getRatingModel() { return $this->getWidgetRelationModelQuery(\nitm\widgets\models\Rating::className()); }