laravel find post by category code example
Example 1: laravel display category post by slug
public function postCategory($id)
{
$posts = Post::where('category_id', $id)->get();
return view('front.posts.category', compact('posts'));
}
Example 2: laravel display category post by slug
Route::get(/category/{slug});
public function postCategory($slug)
{
$posts = Post::where('slug', $slug)->get();
return view('front.posts.category', compact('posts'));
}