/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find()->with('authors'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['id', 'name', 'authorFullName' => ['asc' => ['authors.firstname' => SORT_ASC, 'authors.lastname' => SORT_ASC], 'desc' => ['authors.firstname' => SORT_DESC, 'authors.lastname' => SORT_DESC], 'label' => 'Автор'], 'date_update', 'date_create', 'date']]); $this->load($params); // валидация if (!$this->validate()) { $query->joinWith(['authors']); return $dataProvider; } // Фильтр по Автору $query->joinWith(['authors' => function ($q) { $this->authorFullName = trim($this->authorFullName); if ($this->authorFullName) { $Asearch = str_replace(" ", "|", $this->authorFullName); $q->where('`authors`.`firstname` RLIKE "' . $Asearch . '" ' . 'OR `authors`.`lastname` RLIKE "' . $Asearch . '"'); } }]); /* $query->andFilterWhere([ 'name' => $this->name, 'authors.firstname' => $this->authorFullName, ]);*/ $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['BETWEEN', 'date', $this->date_1, $this->date_2]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::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->author_id) { $query->andFilterWhere(['author_id' => $this->author_id]); } if ($this->date_from) { if ($this->date_till) { $query->andFilterWhere(['date' => ['between', $this->date_from, $this->date_till]]); } else { $query->andFilterWhere(['>=', 'date', $this->date_from]); } } elseif ($this->date_till) { $query->andFilterWhere(['<=', 'date', $this->date_till]); } if ($this->name) { $query->andFilterWhere(['like', 'name', $this->name]); } return $dataProvider; }
public function save() { $model = Books::findOne($this->id); $fileInstance = UploadedFile::getInstance($this, self::FIELD_PREVIEW); if ($fileInstance) { $filePath = 'images/' . $fileInstance->baseName . '.' . $fileInstance->extension; $model->preview = $fileInstance->baseName . '.' . $fileInstance->extension; $fileInstance->saveAs($filePath, false); $imagine = new Gd\Imagine(); try { $filePath = 'images/preview_' . $fileInstance->baseName . '.' . $fileInstance->extension; $img = $imagine->open($fileInstance->tempName); $size = $img->getSize(); if ($size->getHeight() > $this->imageSizeLimit['width'] || $size->getWidth() > $this->imageSizeLimit['height']) { $img->resize(new Box($this->imageSizeLimit['width'], $this->imageSizeLimit['height'])); } $img->save($filePath); // } catch (\Imagine\Exception\RuntimeException $ex) { $this->addError(self::FIELD_PREVIEW, 'Imagine runtime exception: ' . $ex->getMessage()); return FALSE; } } if (!$this->validate()) { return false; } $model->name = $this->name; $model->author_id = $this->author_id; $model->date = DateTime::createFromFormat('d/m/Y', $this->date)->format('Y-m-d'); $model->date_update = new Expression('NOW()'); $model->save(); return true; }
public function search($params) { Yii::$app->session['BooksSearch'] = $params; $query = Books::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]); $dataProvider->setSort(['attributes' => ['id', 'name', 'preview', 'authorfullname' => ['asc' => ['authors.firstname' => SORT_ASC, 'authors.lasttname' => SORT_ASC], 'desc' => ['authors.firstname' => SORT_DESC, 'authors.lasttname' => SORT_DESC], 'label' => Yii::t('app', 'Author'), 'default' => SORT_ASC], 'date', 'date_create']]); $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'); $query->joinWith(['author']); return $dataProvider; } $query->andFilterWhere(['like', 'name', $this->name]); if ($this->date_from) { $query->andFilterWhere(['>=', 'date', $this->date_from]); } if ($this->date_to) { $query->andFilterWhere(['<=', 'date', $this->date_to]); } if ($this->author_id) { $query->andFilterWhere(['author_id' => $this->author_id]); } $query->joinWith(['author']); return $dataProvider; }
/** * Get query for book search * @return [QueryInterface] */ public function getSearchQuery() { $query = Books::find(); //Author $query = $query->filterWhere(['author_id' => $this->author_id]); //Name if (!empty($this->name)) { $query = $query->andWhere(['like', 'name', $this->name]); } //Date if ($this->firstTimestamp != 0 && $this->secondTimestamp != 0) { if ($this->firstTimestamp == $this->secondTimestamp) { $query = $query->andWhere(['=', 'date', $this->firstTimestamp]); } else { $query = $query->andWhere(['between', 'date', $this->firstTimestamp, $this->secondTimestamp]); } } else { if ($this->firstTimestamp != 0) { $query = $query->andWhere(['>=', 'date', $this->firstTimestamp]); } else { if ($this->secondTimestamp != 0) { $query = $query->andWhere(['<=', 'date', $this->secondTimestamp]); } } } return $query; }
protected function findModel($id) { if (($model = Books::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested book not exist.'); } }
private function loadModel($id) { $model = Books::findOne($id); if ($model == NULL) { throw new HttpException(404, 'Model not found.'); } return $model; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $keyword = Input::get('keyword'); if (!$keyword) { $books = Books::orderBy('title', 'ASC')->get(); } else { $books = Books::where('title', 'like', '%' . $keyword . '%')->orWhere('author', 'like', '%' . $keyword . '%')->get(); } return view('catalog.index', compact('books'))->with('result', 'OK'); }
public function actionRemove($id) { if (Yii::$app->request->isAjax) { $model = Books::find()->where(['id' => $id])->one(); $model->delete(); Yii::$app->response->format = Response::FORMAT_JSON; return array('result' => true); } return $this->redirect('index.php?r=site%2Fbooks'); }
public static function getAuthorBooks($author_id, $return_count = true) { $author_id = (int) $author_id; $data = Books::find()->where('authors LIKE "%,' . $author_id . '" OR authors LIKE "%' . $author_id . '," OR authors LIKE "' . $author_id . '"'); if ($return_count) { $data = (int) $data->count(); } else { $data = $data->all(); } return $data; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find()->addSelect([$this->tableName() . ".*", "CONCAT(authors.firstname, ' ', authors.lastname) AS author_fullname"])->joinWith(['author']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['author'] = ['asc' => ['authors.firstname' => SORT_ASC], 'desc' => ['authors.firstname' => SORT_DESC]]; $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; } // поиск по названию книги $query->andFilterWhere(['like', 'books.name', $this->name]); // поиск по дате от/до if (!empty($this->book_date_from) and !empty($this->book_date_to)) { // конвертирую в корректный формат времени и добавляю четкие временные границы $book_date_from = Yii::$app->formatter->asDatetime(str_replace("/", "-", $this->book_date_from), 'dd-MM-yyyy 00:00:00'); $book_date_to = Yii::$app->formatter->asDatetime(str_replace("/", "-", $this->book_date_to), 'dd-MM-yyyy 23:59:59'); $book_date_from = Yii::$app->formatter->asTimestamp($book_date_from); $book_date_to = Yii::$app->formatter->asTimestamp($book_date_to); $query->andFilterWhere(['between', 'books.date', $book_date_from, $book_date_to]); } // поиск по автору if ($this->author_fullname == 7 or in_array(trim(mb_strtolower($this->author)), array('без', 'без привязки', 'без привязки к автору'))) { // для книг без привязки к автору - из books $query->andFilterWhere(['=', 'author_id', 0]); } else { // из authors $query->andFilterWhere(['like', 'authors.firstname', $this->author]); $query->andFilterWhere(['=', 'authors.id', $this->author_fullname]); } /////////////////////// доп параметры для filterModel (если раскомменчены filterModel и Pjax в books/index.php) $query->andFilterWhere(['=', 'books.id', $this->id])->andFilterWhere(['like', 'books.preview', $this->preview]); // дата Выхода книги if (!empty($this->date)) { // конвертирую в корректный формат времени и добавляю четкие временные границы $book_date_from = Yii::$app->formatter->asDatetime(str_replace("/", "-", $this->date), 'dd-MM-yyyy 00:00:00'); $book_date_to = Yii::$app->formatter->asDatetime(str_replace("/", "-", $this->date), 'dd-MM-yyyy 23:59:59'); $book_date_from = Yii::$app->formatter->asTimestamp($book_date_from); $book_date_to = Yii::$app->formatter->asTimestamp($book_date_to); $query->andFilterWhere(['between', 'books.date', $book_date_from, $book_date_to]); } // дата Добавления книги if (!empty($this->date_create)) { // конвертирую в корректный формат времени и добавляю четкие временные границы $book_date_from = Yii::$app->formatter->asDatetime(str_replace("/", "-", $this->date_create), 'dd-MM-yyyy 00:00:00'); $book_date_to = Yii::$app->formatter->asDatetime(str_replace("/", "-", $this->date_create), 'dd-MM-yyyy 23:59:59'); $book_date_from = Yii::$app->formatter->asTimestamp($book_date_from); $book_date_to = Yii::$app->formatter->asTimestamp($book_date_to); $query->andFilterWhere(['between', 'books.date_create', $book_date_from, $book_date_to]); } /////////////////// return $dataProvider; }
public function search($params) { $query = Books::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['author_id' => $this->author_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['<=', 'date', $this->date_to])->andFilterWhere(['>=', 'date', $this->date_from]); return $dataProvider; }
public function dashboard() { // Check Author authentication Session if (!Auth::check('default')) { return $this->redirect('Authors::login'); } // Retrieve current Author ID $author_id = Auth::check('default')->data['id']; // Retrieve Books from the current Author $conditions = array('Books.author_id' => Auth::check('default')->data['id']); $books = Books::find('all', compact('conditions')); return compact('books', 'author_id'); }
public function actionUpload($id) { if (($model = Books::findOne($id)) !== null) { $file = UploadedFile::getInstanceByName('file'); if ($file) { $file->saveAs($model->getCoverPath()); } else { throw new NotFoundHttpException('Failed to load the file.'); } } else { throw new NotFoundHttpException('The book does not exist.'); } }
/** * Updates a new Rents model with closing info. * @return mixed */ public function actionClose() { if (isset($_GET['book_id'])) { if ($model = Rents::find()->where(['book_id' => $_GET['book_id'], 'user_id' => Yii::$app->user->id, 'status' => 'rented'])->one()) { $model->prev_date = date('Y-m-d', time()); $model->status = 'closed'; $model->save(); $book = Books::findOne($model->book_id)->updateStatus('available'); } return $this->redirect(['book/index']); } else { return $this->redirect(['book/index']); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find()->joinWith('bookAuthors')->asArray(); $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; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'issue_year', $this->issue_year])->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'annotation', $this->annotation]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::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; } $query->andFilterWhere(['id' => $this->id, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'date' => $this->date, 'author_id' => $this->author_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['>=', 'date', self::dateFormating($this->firstDate)])->andFilterWhere(['<=', 'date', self::dateFormating($this->secondDate)]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::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; } $query->andFilterWhere(['id' => $this->id, 'author_id' => $this->author_id != 0 ? $this->author_id : ''])->andFilterWhere(['between', 'date', $this->date_start, $this->date_end]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'preview', $this->preview]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::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; } $query->andFilterWhere(['id' => $this->id, 'is_published' => $this->is_published, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'link', $this->link]); return $dataProvider; }
public function delete() { // Check Author authentication Session if (!Auth::check('default')) { return $this->redirect('Authors::login'); } $book = Books::find($this->request->id); if ($book && $book->delete()) { Session::write('message', 'Book deleted'); $this->redirect(array('Authors::dashboard')); } else { Session::write('message', 'Book can not be deleted'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); $query->andFilterWhere(['id' => $this->id, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'date' => $this->date, 'author_id' => $this->author_id]); if (strtotime($this->date_from)) { $query->andFilterWhere(['>=', 'date', strtotime($this->date_from)]); } if (strtotime($this->date_to)) { $query->andFilterWhere(['<=', 'date', strtotime($this->date_to)]); } $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'preview', $this->preview]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find(); // add conditions that should always apply here $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; } $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['author_id' => $this->author_id])->andFilterWhere(['>=', 'date', $this->date_from])->andFilterWhere(['<=', 'date', $this->date_to]); /*->andFilterWhere(['>=', 'date', $this->date_from ? strtotime($this->date_from . ' 00:00:00') : null]) ->andFilterWhere(['<=', 'date', $this->date_to ? strtotime($this->date_to . ' 23:59:59') : null]);*/ return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); $dataProvider->setSort(['attributes' => ['id', 'name', 'date_create', 'date_update', 'date', 'authorName' => ['asc' => ['authors.last_name' => SORT_ASC], 'desc' => ['authors.last_name' => SORT_DESC], 'label' => 'Автор']]]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); $query->joinWith(['author']); return $dataProvider; } $query->andFilterWhere(['books.id' => $this->id, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'date' => $this->date]); // $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere([ // 'like', // 'preview_image', // $this->preview_image // ]); if ($this->author_id) { $query->andFilterWhere(['author_id' => $this->author_id]); } if ($this->name) { $query->andFilterWhere(['like', 'name', $this->name]); } if ($this->date_start && $this->date_end) { $ts1 = strtotime($this->date_start); $ts2 = strtotime($this->date_end); $query->andFilterWhere(['between', 'date', $ts1, $ts2]); } elseif ($this->date_start) { $ts = strtotime($this->date_start); $query->andWhere('date >= :TS', [":TS" => $ts]); } elseif ($this->date_end) { $ts = strtotime($this->date_end); $query->andWhere('date <= :TS', [":TS" => $ts]); } // if ($this->authorName) { // // filter by author name // $query->innerJoinWith([ // 'author' => function ($q) { // $q->where('authors.first_name LIKE "%' . $this->authorName . '%" OR authors.last_name LIKE "%' . $this->authorName . '%"'); // } // ]); // } else { // $query->innerJoinWith(['author']); // } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $group = null) { $query = Books::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; } $query->andFilterWhere(['id' => $this->id, 'book_category_id' => $this->book_category_id, 'views' => $this->views, 'year' => $this->year, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'annotation', $this->annotation])->andFilterWhere(['like', 'authors', $this->authors]); if (!empty($group)) { $query->groupBy([$group]); } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find()->Joinwith('author'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['id', 'name', 'date', 'date_create', 'author.fullName' => ['asc' => ['authors.firstname' => SORT_ASC, 'authors.lastname' => SORT_ASC], 'desc' => ['authors.firstname' => SORT_DESC, 'authors.lastname' => SORT_DESC], 'label' => 'Full Name', 'default' => SORT_ASC]]]); $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; } $query->andFilterWhere(['id' => $this->id, 'author_id' => $this->author_id]); $query->andFilterWhere(['>=', 'date', $this->dateFrom]); $query->andFilterWhere(['<=', 'date', $this->dateTo]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find()->joinWith('author'); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['author_id' => $this->author_id]); $query->andFilterWhere(['like', 'name', $this->name]); if (!empty($this->dateStart)) { $query->andFilterWhere(['>=', 'date', $this->dateStart]); } if (!empty($this->dateEnd)) { $query->andFilterWhere(['<=', 'date', $this->dateEnd]); } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::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; } $query->andFilterWhere(['id' => $this->id, 'author_id' => $this->author_id]); $query->andFilterWhere(['like', 'books.name', $this->name]); $query->joinWith('author'); $dataProvider->sort->attributes['author.name'] = ['asc' => ['vauthors.name' => SORT_ASC], 'desc' => ['vauthors.name' => SORT_DESC]]; if (!(is_null($this->startDate) || is_null($this->endDate) || $this->startDate == '' || $this->endDate == '')) { $query->andFilterWhere(['between', 'date', Yii::$app->formatter->asDatetime($this->startDate, 'yyyy-M-d'), Yii::$app->formatter->asDatetime($this->endDate, 'yyyy-M-d')]); } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { //$this->datefilterstart = date_create_from_format("Y-m-d", $this->datefilterstart)->getTimestamp(); //$this->datefilterend = date_create_from_format("Y-m-d", $this->datefilterstart)->getTimestamp(); $query = Books::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; } $query->andFilterWhere(['author_id' => $this->author_id]); if (!empty($this->datefilterstart) && !empty($this->datefilterend)) { $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['between', 'date', strtotime($this->datefilterstart), strtotime($this->datefilterend)]); } elseif (empty($this->datefilterend)) { $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['between', 'date', strtotime($this->datefilterstart), time()]); } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'date_update' => $this->date_update, 'date' => $this->date, 'author_id' => $this->author_id]); $query->andFilterWhere(['like', 'name', $this->name]); if ($this->min_date != '01/01/1970' && $this->min_date != '1970-01-01') { $query->andFilterWhere(['>=', 'date_create', date('Y-m-d', strtotime(str_replace('/', '-', $this->min_date)))]); } //if ($this->max_date != '01/01/1970') $query->andFilterWhere(['<', 'date_create', date('Y-m-d', strtotime(str_replace('/', '-', $this->max_date)))]); if ($this->max_date != '01/01/1970' && $this->max_date != '1970-01-01' && $this->max_date != '01-01-1970') { if (date('Y-m-d', strtotime(str_replace('/', '-', $this->max_date))) != '1970-01-01') { $query->andFilterWhere(['<', 'date_create', date('Y-m-d', strtotime(str_replace('/', '-', $this->max_date)))]); } } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Books::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; } $query->andFilterWhere(['id' => $this->id, 'author_id' => $this->author_id, 'date_create' => $this->date_create, 'date_update' => $this->date_update, 'date' => $this->date]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'preview', $this->preview]); if (!empty($this->date_start)) { $query->andFilterWhere(['>=', 'date', date('Y-m-d', strtotime($this->date_start))]); } if (!empty($this->date_end)) { $query->andFilterWhere(['<=', 'date', date('Y-m-d', strtotime($this->date_end))]); } return $dataProvider; }