Esempio n. 1
0
 /**
  * Displays a single Product model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $ingredients = new ActiveDataProvider(['query' => Ingredients::find()->where(['product_id' => $id, 'status' => [Status::STATUS_ACTIVE]])]);
     $productReviews = new ActiveDataProvider(['query' => \common\models\ProductReview::find()->where(['product_id' => $id, 'status' => [Status::STATUS_ACTIVE]])]);
     $productPhotos = new ActiveDataProvider(['query' => ProductPhoto::find()->where(['product_id' => $id, 'status' => [Status::STATUS_ACTIVE]])]);
     return $this->render('view', ['model' => $this->findModel($id), 'ingredients' => $ingredients, 'productReviews' => $productReviews, 'productPhotos' => $productPhotos]);
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductReview::find();
     $dataProvider = new ActiveDataProvider(['query' => $query->where(['status' => [Status::STATUS_ACTIVE, Status::STATUS_INACTIVE]])]);
     $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, 'stars' => $this->stars, 'product_id' => $this->product_id, 'user_id' => $this->user_id, 'sn_review_id' => $this->sn_review_id, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'modified_by', $this->modified_by]);
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProductReviews()
 {
     return $this->hasMany(ProductReview::className(), ['user_id' => 'id']);
 }
 /**
  * Finds the ProductReview model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProductReview the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProductReview::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }