From 9fe537255486a2e9204033bb8b6313172d3353b9 Mon Sep 17 00:00:00 2001 From: evgenmil Date: Thu, 14 May 2015 13:46:11 +0600 Subject: [PATCH] Update News.php Add find by slug --- modules/news/api/News.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/news/api/News.php b/modules/news/api/News.php index b0d8e1c..e195106 100644 --- a/modules/news/api/News.php +++ b/modules/news/api/News.php @@ -55,7 +55,7 @@ public function api_last($limit = 1) public function api_get($id) { - if(!($news = NewsModel::findOne(['news_id' => $id, 'status' => NewsModel::STATUS_ON]))){ + if(!($news = NewsModel::find()->where(['or', 'news_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id])->andWhere(['and', 'status=:st'], [':st' => NewsModel::STATUS_ON])->one())){ return $this->notFound(); } @@ -138,4 +138,4 @@ private function notFound() return $this->createObject($this->errorText('WRONG NEWS_ID')); } } -} \ No newline at end of file +}