Example #1
0
 public function actionSearch()
 {
     $get = Yii::$app->getRequest()->get();
     $val = null;
     if (isset($get['so'])) {
         $soarr = explode('_', $get['so']);
         $val = $soarr[1];
     }
     $query = AvRel::find()->where(['status' => AvRel::STATUS_ACTIVE]);
     $query->andFilterWhere(['category_id' => $get['cate']])->andFilterWhere(['av_id' => $val]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $avs = $query->offset($pages->offset)->limit($pages->limit)->select('goods_id')->asArray()->all();
     $avs = ArrayHelper::getColumn($avs, 'goods_id');
     $goods = Goods::find()->where(['status' => Goods::STATUS_ACTIVE])->andWhere(['id' => $avs])->asArray()->all();
     $covers = ArrayHelper::getColumn($goods, 'cover');
     $covers = Attachment::find()->where(['id' => $covers])->indexBy('id')->asArray()->all();
     foreach ($goods as &$v) {
         if (empty($v['cover'])) {
             continue;
         }
         $co = $covers[$v['cover']];
         $v['img'] = $co['path'] . '/tiny_' . $co['name'];
     }
     return $this->ajaxReturn(['list' => $goods]);
 }
Example #2
0
    <?php 
$i = 1;
foreach ($cates as $ck => $v) {
    ?>
      <div id="tab_<?php 
    echo $ck;
    ?>
" class="tab <?php 
    if ($i == 1) {
        echo 'active';
    }
    ?>
" p="1" more="1">
         <div class="row no-gutter">
          <?php 
    $attrs = AvRel::attrs($v['id']);
    if ($attrs) {
        ?>
            <div class="col-20">
              <div class="list-block hs-nomargin">
                <ul>

                <?php 
        foreach ($attrs as $k => $attr) {
            ?>
                  <li class="list-group-title"><?php 
            echo $attr['name'];
            ?>
</li>
                    <?php 
            foreach ($attr['child'] as $key => $val) {