Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Assets::find();
     $query->joinWith('assettype');
     $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;
     }
     $dataProvider->sort->attributes['typename'] = ['asc' => ['Assettypes.typename' => SORT_ASC], 'desc' => ['Assettypes.typename' => SORT_DESC]];
     //        $query->andFilterWhere([
     //            'recid' => $this->recid,
     //            'assettypeid' => $this->assettypeid,
     //            'createdate' => $this->createdate,
     //        ]);
     $query->orFilterWhere(['like', 'assetname', $this->globalSearch])->orFilterWhere(['like', 'Assets.description', $this->globalSearch])->orFilterWhere(['like', 'typename', $this->globalSearch]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAssets()
 {
     return $this->hasMany(Assets::className(), ['assettypeid' => 'recid']);
 }