backend/models/DeliverySearch.php
/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param array $params


Creates data provider instance with search query applied @param array $params
public function search($params)
    {
        $query = Delivery::find();
        if(empty($params) || empty($params['DeliverySearch']['nomor_barcode'])){
            $query = Delivery::find()->where(['id' => NULL]);
        }
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'  => ['defaultOrder' => ['id' => SORT_DESC]]
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'id' => $this->id,
        ]);
        $query->andFilterWhere(['like', 'nama', $this->nama])
            ->andFilterWhere(['like', 'nomor_barcode', $this->nomor_barcode])
            ->andFilterWhere(['like', 'alamat', $this->alamat])
            ->andFilterWhere(['like', 'pengantar', $this->pengantar])
            ->andFilterWhere(['like', 'tanggal_terima', $this->tanggal_terima])
            ->andFilterWhere(['like', 'tanggal_setor', $this->tanggal_setor])
            ->andFilterWhere(['like', 'pp25', $this->pp25])
            ->andFilterWhere(['like', 'pp15', $this->pp15]);
        return $dataProvider;
    }
public function search ( $ params ) { $ query = Delivery :: find ( ) ; if ( empty ( $ params ) || empty ( $ params [ 'DeliverySearch' ] [ 'nomor_barcode' ] ) ) { $ query = Delivery :: find ( ) -> where ( [ 'id' => NULL ] ) ; } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'id' => SORT_DESC ] ] ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'id' => $ this -> id , ] ) ; $ query -> andFilterWhere ( [ 'like' , 'nama' , $ this -> nama ] ) -> andFilterWhere ( [ 'like' , 'nomor_barcode' , $ this -> nomor_barcode ] ) -> andFilterWhere ( [ 'like' , 'alamat' , $ this -> alamat ] ) -> andFilterWhere ( [ 'like' , 'pengantar' , $ this -> pengantar ] ) -> andFilterWhere ( [ 'like' , 'tanggal_terima' , $ this -> tanggal_terima ] ) -> andFilterWhere ( [ 'like' , 'tanggal_setor' , $ this -> tanggal_setor ] ) -> andFilterWhere ( [ 'like' , 'pp25' , $ this -> pp25 ] ) -> andFilterWhere ( [ 'like' , 'pp15' , $ this -> pp15 ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params
// add conditions that should always apply here // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); // grid filtering conditions