public function actionBrandView($lang = null, $alias) { $brand = Brand::find()->lang($lang)->andWhere(['alias' => $alias])->one(); if (!$brand) { throw new HttpException(404, 'Брэнд не найден'); } if (\Yii::$app->request->isAjax) { return $this->renderAjax('brandView', ['brand' => $brand]); } return $this->render('brandView', ['brand' => $brand]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Brand::find()->lang(); $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, 'position' => $this->position]); $query->andFilterWhere(['like', 'lang', $this->lang])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'descriptionShort', $this->descriptionShort])->andFilterWhere(['like', 'alias', $this->alias]); return $dataProvider; }
public function getBrand() { return $this->hasOne(Brand::className(), ['id' => 'brandId'])->andWhere(['lang' => \Yii::$app->language]); }
<?php /** * Created by PhpStorm. * User: ivphpan * Date: 19.01.16 * Time: 18:06 */ /** @var $brandList \app\modules\catalog\models\Brand*/ $brandList = \app\modules\catalog\models\Brand::find()->lang()->all(); ?> <div class="brand-logo bounceInUp animated"> <div class="container"> <div class="slider-items-products"> <div id="brand-logo-slider" class="product-flexslider hidden-buttons"> <div class="slider-items slider-width-col6"> <?php foreach ($brandList as $brand) { ?> <!-- Item --> <div class="item"> <a href="<?php echo $brand->url; ?> "><img src="<?php echo $brand->imageSrc('130x50', \yii\image\drivers\Image::AUTO, 1); ?> " alt="Image"></a> </div> <!-- End Item -->
<?php use app\modules\catalog\models\CategoryRecord; /* @var $this yii\web\View */ /* @var $model app\modules\catalog\models\CategoryRecord */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="category-record-form"> <div class="well"> <div class="row"> <div class="col-md-4"> <?php echo $form->field($model, '[' . $k . ']brandId')->dropDownList(\app\modules\catalog\models\Brand::dropdown(), ['prompt' => '-']); ?> <?php echo $form->field($model, '[' . $k . ']title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, '[' . $k . ']alias')->textInput(['maxlength' => true]); ?> <small><?php echo $model->FullPath; ?> </small>