fix news post sorting

This commit is contained in:
flash 2017-03-22 20:51:50 +01:00
parent ca6309f3b4
commit 3413efd825
3 changed files with 3 additions and 1 deletions

View file

@ -64,6 +64,7 @@ class HomeController extends Controller
->whereNull('deleted_at') ->whereNull('deleted_at')
->whereIn('category_id', explode(',', config('general.homepage-news'))) ->whereIn('category_id', explode(',', config('general.homepage-news')))
->limit(3) ->limit(3)
->orderBy('created_at', 'desc')
->get(); ->get();
$news = array_map(function (stdClass $row) { $news = array_map(function (stdClass $row) {

View file

@ -38,6 +38,7 @@ class NewsController extends Controller
->where('news_categories.category_hidden', '=', 0); ->where('news_categories.category_hidden', '=', 0);
}) })
->limit(5) ->limit(5)
->orderBy('created_at', 'desc')
->get(); ->get();
$posts = array_map(function (stdClass $row) { $posts = array_map(function (stdClass $row) {

View file

@ -77,7 +77,7 @@ class Category
{ {
if (!$this->postsCache) { if (!$this->postsCache) {
$posts = DB::table('news_posts') $posts = DB::table('news_posts')
->orderBy('post_id', 'desc'); ->orderBy('created_at', 'desc');
if ($this->id !== 0) { if ($this->id !== 0) {
$posts->where('category_id', $this->id); $posts->where('category_id', $this->id);