/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Stack::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;
     }
     if ($this->created_at) {
         $date = explode(' - ', $this->created_at);
         if (count($date) == 2) {
             $query->andFilterWhere(['>=', $this::tableName() . '.created_at', $date[0] . ' 00:00:00']);
             $query->andFilterWhere(['<=', $this::tableName() . '.created_at', $date[1] . ' 23:59:59']);
         }
     }
     if ($this->updated_at) {
         $date = explode(' - ', $this->updated_at);
         if (count($date) == 2) {
             $query->andFilterWhere(['>=', $this::tableName() . '.updated_at', $date[0] . ' 00:00:00']);
             $query->andFilterWhere(['<=', $this::tableName() . '.updated_at', $date[1] . ' 23:59:59']);
         }
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'price' => $this->price])->andFilterWhere(['like', 'stack.code', $this->code])->andFilterWhere(['like', 'stack.name', $this->name]);
     return $dataProvider;
 }
 public function setStackId($stack_id = null)
 {
     if ($stack_id) {
         $this->stack_id = $stack_id;
     } else {
         $stack = Stack::find()->where(['=', 'code', $this->stackcode])->one();
         if ($stack) {
             $this->stack_id = $stack->id;
         }
     }
 }