Example #1
0
 /**
  * @access public
  * @param $pid 节点的id
  * @param array 返回该节点的所有后代节点
  */
 public function list_cate($pid = 0)
 {
     //以数组形式获取所有的记录
     $cates = GoodsCategory::find()->asArray()->all();
     //对类别进行重组,并返回
     return $this->_tree($cates, $pid);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = GoodsCategory::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])->andFilterWhere(['like', 'descr', $this->descr]);
     return $dataProvider;
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(GoodsCategory::className(), ['id' => 'category_id']);
 }
Example #4
0
?>
</h1>
                    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

                    <p>
                        <?php 
echo Html::a('Создать товар', ['create'], ['class' => 'btn btn-success']);
?>
                    </p>

                    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'item', 'format' => 'html', 'value' => function ($dataProvider) {
    return Html::a($dataProvider->item, '/goods/default/view?id=' . $dataProvider->id);
}], ['attribute' => 'category_id', 'format' => 'html', 'value' => function ($dataProvider) {
    return GoodsCategory::find()->where(['id' => $dataProvider->category_id])->one()->getName();
}], 'quantity', 'price', ['attribute' => 'image', 'format' => 'html', 'value' => function ($dataProvider) {
    if ($dataProvider->image) {
        return Html::img('/upload/goods/' . $dataProvider->image, ['height' => '100px']);
    } else {
        return '';
    }
}, 'label' => 'Предпросмотр'], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

                </div>
            </div>
        </div>
    </div>
</div>
Example #5
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div id="content">
    <div class="outer">
        <div class="inner bg-light lter">
            <div id="collapse4" class="body">
<div class="shop-view">

    <h1><?php 
echo 'Товар: ' . Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['item', 'price', 'rating', ['attribute' => 'category_id', 'format' => 'raw', 'value' => Html::a(GoodsCategory::find()->where(['id' => $model->category_id])->one()->getName(), '/goods_category/default/view?id=' . $model->category_id)], 'quantity', 'descr:ntext', 'status', ['attribute' => 'image', 'value' => isset($model->image) && $model->image != '' ? '/upload/goods/' . $model->image : '/img-custom/no_photo.jpg', 'format' => ['image', ['width' => '300', 'height' => '300']]]]]);
?>

</div>
</div>
</div>
</div>
</div>
 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]);
 }
 /**
  * Finds the GoodsCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return GoodsCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = GoodsCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #8
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]);
?>
Example #9
0
 public function actionGoodsadd()
 {
     //获取商品类型及其属性
     $type = GoodsType::find()->all();
     //获取商品分类信息
     $category = new GoodsCategory();
     $cate = $category->list_cate();
     //获取商品品牌信息
     $brand = GoodsBrand::find()->all();
     $model = new Goods();
     return $this->render('goodsadd', ['type' => $type, 'cate' => $cate, 'brand' => $brand, 'model' => $model]);
 }