Skip to content

Commit

Permalink
Update News.php
Browse files Browse the repository at this point in the history
Add find by slug
  • Loading branch information
evgenmil committed May 14, 2015
1 parent 451a11c commit 9fe5372
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/news/api/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -138,4 +138,4 @@ private function notFound()
return $this->createObject($this->errorText('WRONG NEWS_ID'));
}
}
}
}

0 comments on commit 9fe5372

Please sign in to comment.