示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Brend::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]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#2
0
 public function actionDetail()
 {
     $data = $this->getCommonDate();
     $modelBest = Goods::getBest(3);
     $iP = Yii::$app->session->id;
     $quantityInCart = Cart::getQountAllByIp($iP);
     $id = Yii::$app->request->get('item');
     $modelReview = Review::getReviewsByGoodId($id);
     $modelGoodsCategories = GoodsCategory::find()->all();
     $modelBrends = Brend::find()->all();
     if (!$id) {
         $this->redirect('/shop/index');
     }
     $model = Goods::getItemById($id);
     $modelPhotos = GoodsPhotos::getItemsByGoodId($id);
     $_modelReview = new Review();
     return $this->render('detail', ['modelPhotos' => $modelPhotos, 'data' => $data, 'model' => $model, 'modelGoodsCategories' => $modelGoodsCategories, 'modelReview' => $modelReview, '_modelReview' => $_modelReview, 'modelBest' => $modelBest, 'modelBrends' => $modelBrends]);
 }
示例#3
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\GoodsCategory;
use backend\assets\AppAsset;
use common\models\Brend;
$this->registerJsFile('/js/custom/upload_goods.js', ['depends' => AppAsset::className()]);
$arrGoodsCategory = GoodsCategory::find()->all();
$arrBrend = Brend::find()->all();
?>

<div class="shop-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'], 'id' => 'form-send-file']);
?>

    <?php 
echo $form->field($model, 'item')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'price')->textInput();
?>

    <?php 
echo $form->field($model, 'rating')->dropDownList([1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5]);
?>