コード例 #1
0
ファイル: ListingSearch.php プロジェクト: sea129/kbay
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Listing::find()->innerJoin('ebay_account', 'listing.ebay_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(['id' => $this->id, 'ebay_id' => $this->ebay_id, 'price' => $this->price, 'qty' => $this->qty, 'sold_qty' => $this->sold_qty, 'sync_at' => $this->sync_at]);
     $query->andFilterWhere(['like', 'item_id', $this->item_id])->andFilterWhere(['like', 'sku', $this->sku])->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: ProductController.php プロジェクト: sea129/kbay
 /**
  * Displays a single Product model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $product = $this->findModel($id);
     $listings = Listing::find()->where(['sku' => $product->sku, 'user_id' => Yii::$app->user->id])->indexBy('ebay_id')->all();
     return $this->render('view', ['model' => $product, 'listings' => $listings]);
 }
コード例 #3
0
ファイル: ListingController.php プロジェクト: sea129/kbay
 /**
  * Finds the Listing model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Listing the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Listing::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }