/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ImagesCommon::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'is_active' => $this->is_active, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'hash', $this->hash])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'exp', $this->exp]); return $dataProvider; }
public function actionSize() { $status = true; $get = Yii::$app->request->get(); $image = ImagesCommon::find()->where(['path' => $get['path'], 'name' => $get['name']])->active()->one(); if ($image) { $url = $image->getImage($get['size']); } else { $message = 'Не найдено изображение'; } if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ['status' => $status, 'url' => 'http://' . $this->module->domain . $url, 'message' => $message]; } if (empty($url)) { throw new NotFoundHttpException(); } return $url; }