/** * Displays profile homepage. * * @return mixed */ public function actionIndex($code = null) { $codes = Yii::$app->user->identity->availableCodes; $allCodes = array_merge($codes, Yii::$app->user->identity->availableGroupCodes); $campaigns = CodeBankCampaign::find()->where(['codeBank_code' => $allCodes])->all(); $model = CodeBank::find()->where(['code' => $codes])->all(); return $this->render('index', ['model' => $model, 'roleOptions' => $this->roleOptions, 'allCodes' => $allCodes, 'selectedCode' => $code, 'campaigns' => $campaigns]); }
public function actionUpdateTopup() { $result = \Yii::$app->request->post(); foreach ($result as $key => $value) { Yii::$app->db->createCommand('Update toppupBank set code=:code , used=1 where order_product_id=:key')->bindValue(':code', $value)->bindValue(':key', $key)->execute(); $codeBank = CodeBank::find()->where(['code' => $value])->one(); // Get Topup id $orderProduct = OrderProduct::findOne($key); // Get topup maxCallOut $tp = Topup::findOne($orderProduct->objectId); $codeBank->updateCounters(['maxCallout' => $tp->maxCallOut]); } return 1; }