Answer the question
In order to leave comments, you need to log in
Laravel - how to display all news from a category and specify the news category in the URL?
There is news, displayed at address http://127.0.0.1:8000/post/1
1 is the ID of the news, the news has a category.
How to implement news output at the addresshttp://127.0.0.1:8000/имя_категории/ид_новости
Answer the question
In order to leave comments, you need to log in
Route::get('/{category}/{id}')
//
public function post(string $category, int $id): View
{
$post = Post::findOrFail($id);
return view('post', compact('post'));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question