public function actionLanding() { $packages = Package::find()->where(['enable' => 1])->limit(4)->orderBy('position')->all(); $toppups = Topup::find()->where(['enable' => 1])->limit(4)->orderBy('position')->all(); $this->layout = 'unify/front_page'; $temp = new HybrizyCartForm(); $session = Yii::$app->user->isGuest ? $temp->loadSession('Hybrizy') : $temp->loadFromTable(); if ($session == false) { $cart = ['totalCount' => 0]; } else { $cart = $session; } return $this->render('landing', ['packages' => $packages, 'toppups' => $toppups, 'cart' => $cart]); }
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; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Topup::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'unitPrice' => $this->unitPrice, 'maxCallOut' => $this->maxCallOut, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at, 'update_by' => $this->update_by, 'created_by' => $this->created_by, 'position' => $this->position, 'enable' => $this->enable, 'price' => $this->price, 'limitBy' => $this->limitBy, 'quota' => $this->quota]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Finds the Topup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Topup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Topup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }