backend/models/search/HotelBookingSearch.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,$confirmed)
    {
        if($confirmed){
            $query = HotelBooking::find()->where(['is_confirmed' => 1]);
        }else{
            $query = HotelBooking::find()->where(['is_confirmed' => 0]);
        }
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'id' => $this->id,
            'room_id' => $this->room_id,
            'menu_id' => $this->menu_id,
            'start_date' => $this->start_date,
            'end_date' => $this->end_date,
            'price' => $this->price,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
            'deleted_at' => $this->deleted_at,
        ]);
        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'surname', $this->surname])
            ->andFilterWhere(['like', 'pid', $this->pid])
            ->andFilterWhere(['like', 'country', $this->country])
            ->andFilterWhere(['like', 'city', $this->city])
            ->andFilterWhere(['like', 'mobile', $this->mobile])
            ->andFilterWhere(['like', 'email', $this->email]);
        return $dataProvider;
    }
public function search ( $ params , $ confirmed ) { if ( $ confirmed ) { $ query = HotelBooking :: find ( ) -> where ( [ 'is_confirmed' => 1 ] ) ; } else { $ query = HotelBooking :: find ( ) -> where ( [ 'is_confirmed' => 0 ] ) ; } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , ] ) ; if ( ! ( $ this -> load ( $ params ) && $ this -> validate ( ) ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'id' => $ this -> id , 'room_id' => $ this -> room_id , 'menu_id' => $ this -> menu_id , 'start_date' => $ this -> start_date , 'end_date' => $ this -> end_date , 'price' => $ this -> price , 'created_at' => $ this -> created_at , 'updated_at' => $ this -> updated_at , 'deleted_at' => $ this -> deleted_at , ] ) ; $ query -> andFilterWhere ( [ 'like' , 'name' , $ this -> name ] ) -> andFilterWhere ( [ 'like' , 'surname' , $ this -> surname ] ) -> andFilterWhere ( [ 'like' , 'pid' , $ this -> pid ] ) -> andFilterWhere ( [ 'like' , 'country' , $ this -> country ] ) -> andFilterWhere ( [ 'like' , 'city' , $ this -> city ] ) -> andFilterWhere ( [ 'like' , 'mobile' , $ this -> mobile ] ) -> andFilterWhere ( [ 'like' , 'email' , $ this -> email ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params