Refactor News management features: replace author text input with a searchable select component in NewsResource, update NewsPageController to fetch news with authors and recent articles, and enhance the news show view to display author details and comments more effectively.
This commit is contained in:
@@ -9,14 +9,17 @@ class NewsPageController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$allNews = News::all();
|
||||
$allNews = News::query()->with('author')->latest()->get();
|
||||
|
||||
return view('web.pages.news.index', compact('allNews'));
|
||||
}
|
||||
|
||||
public function show(News $news)
|
||||
public function show($news)
|
||||
{
|
||||
return view('web.pages.news.show', compact('news'));
|
||||
$news = News::where('slug', $news)->with('author', 'comments')->first();
|
||||
$recentNews = News::query()->with('author')->latest()->limit(3)->get();
|
||||
|
||||
return view('web.pages.news.show', compact('news', 'recentNews'));
|
||||
}
|
||||
|
||||
public function storeComment(Request $request, News $news)
|
||||
|
||||
Reference in New Issue
Block a user