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:
2025-07-28 21:05:24 +05:00
parent 1b4989b440
commit 6b0c92d838
12 changed files with 360 additions and 52 deletions

View File

@@ -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)