Check out example codes for "laravel display category post by slug". It will help you in understanding the concepts better.

Code Example 1

Route::get(/category/{slug});

    public function postCategory($slug)
    {
        $posts = Post::where('slug', $slug)->get();

        return view('front.posts.category', compact('posts'));
    }

Code Example 2

public function postCategory($id)
    {
        $posts = Post::where('category_id', $id)->get();

        return view('front.posts.category', compact('posts'));
    }

Learn ReactJs, React Native from akashmittal.com