/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductCategoryTranslation::find();
     if (!empty($params['product_category_id'])) {
         $query->where(['product_category_id' => $params['product_category_id']]);
     }
     $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, 'product_category_id' => $this->product_category_id, 'language_id' => $this->language_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'search_text', $this->search_text])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'page_title', $this->page_title])->andFilterWhere(['like', 'h1', $this->h1])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'image_path', $this->image_path]);
     return $dataProvider;
 }
示例#2
0
 public function t($column = null, $language_id = null)
 {
     if ($language_id == null) {
         $language_id = Yii::$app->session->get('language_id');
     }
     if ($this->_product_category_translation === null) {
         if (!($this->_product_category_translation = ProductCategoryTranslation::find()->where(['product_category_id' => $this->id])->andWhere(['language_id' => $language_id])->one())) {
             if (!($this->_product_category_translation = ProductCategoryTranslation::find()->where(['product_category_id' => $this->id])->andWhere(['language_id' => Language::getDefault()->id])->one())) {
                 if (!($this->_product_category_translation = ProductCategoryTranslation::find()->where(['product_category_id' => $this->id])->orderBy('id asc')->one())) {
                     $this->_product_category_translation = new ProductCategoryTranslation();
                 }
             }
         }
     }
     if ($column == null) {
         return $this->_product_category_translation;
     }
     return $this->_product_category_translation->{$column};
 }
示例#3
0
文件: _form.php 项目: quyettvq/luspel
use yii\web\View;
use yii\widgets\ActiveForm;
/* @var $this View */
/* @var $model ProductCategoryTranslation */
/* @var $form ActiveForm */
?>

<div class="product-category-translation-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <div class="col-md-6">
        <?php 
echo $form->field($model, 'language_id')->dropDownList(array_diff_key($this->context->languages_idToName, ArrayHelper::map(ProductCategoryTranslation::find()->where(['product_category_id' => $model->product_category_id])->andWhere(['<>', 'id', (int) $model->id])->all(), 'language_id', 'language_id')));
?>
        <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
        <?php 
echo $form->field($model, 'product_category_id')->textInput(['readonly' => true, 'type' => 'hidden'])->label(false);
?>
        <?php 
// echo $form->field($model, 'search_text')->textInput(['maxlength' => true])->label()
?>
    </div>
    <div class="col-md-6">
        <?php 
echo $form->field($model, 'page_title')->textInput(['maxlength' => true]);
?>