/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PhotoLibrary::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
     $query->andFilterWhere(['like', 'ref', $this->ref])->andFilterWhere(['like', 'event_name', $this->event_name])->andFilterWhere(['like', 'detail', $this->detail])->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'province', $this->province])->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'customer_mobile_phone', $this->customer_mobile_phone]);
     return $dataProvider;
 }
 public function actionDeletefileAjax()
 {
     $model = Uploads::findOne(Yii::$app->request->post('key'));
     if ($model !== NULL) {
         $filename = PhotoLibrary::getUploadPath() . $model->ref . '/' . $model->real_filename;
         $thumbnail = PhotoLibrary::getUploadPath() . $model->ref . '/thumbnail/' . $model->real_filename;
         if ($model->delete()) {
             @unlink($filename);
             @unlink($thumbnail);
             echo json_encode(['success' => true]);
         } else {
             echo json_encode(['success' => false]);
         }
     } else {
         echo json_encode(['success' => false]);
     }
 }