public function actionIndex() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $pagination = new Pagination(['defaultPageSize' => 6, 'totalCount' => Product::find()->count()]); $countries = Product::find()->orderBy('AddTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render(Variable::$productManger_view, ['countries' => $countries, 'pagination' => $pagination]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Product::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, 'power' => $this->power, 'light_source' => $this->light_source, 'input_voltage' => $this->input_voltage, 'load_capacity' => $this->load_capacity, 'high_cut' => $this->high_cut, 'low_cut' => $this->low_cut, 'created' => $this->created, 'created_by' => $this->created_by]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'warranty', $this->warranty])->andFilterWhere(['like', 'case', $this->case])->andFilterWhere(['like', 'body_color', $this->body_color])->andFilterWhere(['like', 'ip_grade', $this->ip_grade])->andFilterWhere(['like', 'quality_approved', $this->quality_approved])->andFilterWhere(['like', 'place_of_origin', $this->place_of_origin]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Product::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, 'availability' => $this->availability, 'price' => $this->price, 'rating' => $this->rating, 'top' => $this->top, 'user_id' => $this->user_id, 'category_id' => $this->category_id]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'brand', $this->brand])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'short_description', $this->short_description])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'image_alt', $this->image_alt])->andFilterWhere(['like', 'currency', $this->currency])->andFilterWhere(['like', 'vendor', $this->vendor]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Product::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $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, 'price' => $this->price, 'original_price' => $this->original_price, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status, 'is_active' => $this->is_active, 'is_hot' => $this->is_hot, 'position' => $this->position, 'published_at' => $this->published_at, 'view_count' => $this->view_count, 'comment_count' => $this->comment_count, 'share_count' => $this->share_count, 'like_count' => $this->like_count, 'available_quantity' => $this->available_quantity, 'order_quantity' => $this->order_quantity, 'sold_quantity' => $this->sold_quantity, 'total_quantity' => $this->total_quantity, 'total_revenue' => $this->total_revenue]); $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'old_slugs', $this->old_slugs])->andFilterWhere(['like', 'image_path', $this->image_path])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'updated_by', $this->updated_by]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Product::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, 'gallery_id' => $this->gallery_id]); $query->andFilterWhere(['like', 'product', $this->product])->andFilterWhere(['like', 'file_name', $this->file_name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Product::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'is_featured' => $this->is_featured, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'desc', $this->desc]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Product::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->joinWith('user'); $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'user.username', $this->user_id]); return $dataProvider; }
public static function getProductName() { $products = Product::find()->all(); $listData = ArrayHelper::map($products, 'id', 'name'); return $listData; }
?> <div class="order-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'user_id')->textInput(array('readonly' => true, 'value' => Yii::$app->user->identity->id)); ?> <?php echo $form->field($model, 'username')->textInput(array('readonly' => true, 'value' => Yii::$app->user->identity->username)); ?> <?php $products = Product::find()->all(); $listData = ArrayHelper::map($products, 'id', 'name'); echo $form->field($model, 'product_id')->dropDownList($listData, ['prompt' => 'Select Product...']); ?> <?php echo $form->field($model, 'qty')->textInput(['maxlength' => 45]); ?> <?php echo $form->field($model, 'date')->textInput(['maxlength' => 45]); ?> <?php echo $form->field($model, 'Status')->textInput(['maxlength' => 255]); ?>
public function actionReviewCreate() { $model = new Review(); $products = Product::find()->where(['top' => Product::STATUS_TOP, 'category_id' => 1])->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $model->sendEmail('Новый Отзыв', 'review'); Yii::$app->session->addFlash('success', 'Спасибо за Ваш отзыв! Отзыв проходит модерацию.'); return $this->goHome(); } else { return $this->render('index', ['review' => $model, 'products' => $products]); } }