/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProductEbayListing::find()->innerJoin('ebay_account', 'product_ebay_listing.ebay_account_id = ebay_account.id')->where(['ebay_account.user_id' => Yii::$app->user->id]); $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(['ebay_account_id' => $this->ebay_account_id, 'price' => $this->price, 'updated_at' => $this->updated_at, 'qty' => $this->qty, 'qty_sold' => $this->qty_sold]); $query->andFilterWhere(['like', 'sku', $this->sku])->andFilterWhere(['like', 'item_id', $this->item_id])->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
/** * Displays a single EbayAccount model. * @param integer $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); $synListingInfo = ProductEbayListing::find()->allOfEbay($id, $db = null); return $this->render('view', ['model' => $model, 'synListingInfo' => $synListingInfo]); }
/** * Finds the ProductEbayListing model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return ProductEbayListing the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProductEbayListing::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }