Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Brand::find();
     $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, 'sort' => $this->sort, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
use common\models\catalog\Category;
use common\models\catalog\Brand;
use backend\assets\DatePickerAsset;
/* @var $this yii\web\View */
/* @var $model common\models\catalog\Product */
/* @var $form yii\widgets\ActiveForm */
//加载一插件
DatePickerAsset::register($this);
//使用插件
$this->registerJs("\n\t\$('#product-promote_start_date, #product-promote_end_date').datepicker({\n        language: '" . Yii::$app->language . "',//使用当前语言\n\t    format: 'yyyy/mm/dd'\n\t});\n");
$model->promote_start_date = Yii::$app->getFormatter()->asDate($model->promote_start_date, 'yyyy/MM/dd');
//与js配合
$model->promote_end_date = Yii::$app->getFormatter()->asDate($model->promote_end_date, 'yyyy/MM/dd');
//与js配合
$cateList = ArrayHelper::map(General::recursiveObj(Category::find()->orderBy(['sort' => SORT_ASC])->all()), 'id', 'name');
$brandList = ArrayHelper::map(Brand::find()->orderBy(['sort' => SORT_ASC])->all(), 'id', 'name');
?>

<!-- 导航 -->
<div id="product_nav">
    <ul>
        <li><a href="#home"><?php 
echo Yii::t('catalog', 'Base');
?>
</a></li>
        <li><a href="#declare"><?php 
echo Yii::t('catalog', 'Declare');
?>
</a></li>
        <li><a href="#price"><?php 
echo Yii::t('catalog', 'Price');