updated gallery
This commit is contained in:
@@ -35,21 +35,10 @@ class NewsController extends Controller
|
||||
}
|
||||
|
||||
$articles = $query->paginate($perPage);
|
||||
$categories = NewsCategory::active()->withCount('publishedArticles')->ordered()->get();
|
||||
$trending = NewsArticle::published()
|
||||
->orderByDesc('views')
|
||||
->limit(config('news.trending_limit', 5))
|
||||
->get(['id', 'title', 'slug', 'views', 'published_at']);
|
||||
|
||||
$tags = NewsTag::has('articles')->orderBy('name')->get();
|
||||
|
||||
return view('news.index', [
|
||||
'featured' => $featured,
|
||||
'articles' => $articles,
|
||||
'categories' => $categories,
|
||||
'trending' => $trending,
|
||||
'tags' => $tags,
|
||||
]);
|
||||
] + $this->sidebarData());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -67,13 +56,10 @@ class NewsController extends Controller
|
||||
->orderByDesc('published_at')
|
||||
->paginate($perPage);
|
||||
|
||||
$categories = NewsCategory::active()->withCount('publishedArticles')->ordered()->get();
|
||||
|
||||
return view('news.category', [
|
||||
'category' => $category,
|
||||
'articles' => $articles,
|
||||
'categories' => $categories,
|
||||
]);
|
||||
] + $this->sidebarData());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -91,13 +77,10 @@ class NewsController extends Controller
|
||||
->orderByDesc('published_at')
|
||||
->paginate($perPage);
|
||||
|
||||
$categories = NewsCategory::active()->withCount('publishedArticles')->ordered()->get();
|
||||
|
||||
return view('news.tag', [
|
||||
'tag' => $tag,
|
||||
'articles' => $articles,
|
||||
'categories' => $categories,
|
||||
]);
|
||||
] + $this->sidebarData());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -126,7 +109,7 @@ class NewsController extends Controller
|
||||
return view('news.show', [
|
||||
'article' => $article,
|
||||
'related' => $related,
|
||||
]);
|
||||
] + $this->sidebarData());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -154,4 +137,16 @@ class NewsController extends Controller
|
||||
|
||||
$request->session()->put($session, true);
|
||||
}
|
||||
|
||||
private function sidebarData(): array
|
||||
{
|
||||
return [
|
||||
'categories' => NewsCategory::active()->withCount('publishedArticles')->ordered()->get(),
|
||||
'trending' => NewsArticle::published()
|
||||
->orderByDesc('views')
|
||||
->limit(config('news.trending_limit', 5))
|
||||
->get(['id', 'title', 'slug', 'views', 'published_at']),
|
||||
'tags' => NewsTag::has('articles')->orderBy('name')->get(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user