Answers for "laravel display category post by slug"

PHP
0

laravel display category post by slug

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

        return view('front.posts.category', compact('posts'));
    }
Posted by: Guest on September-28-2020
0

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'));
    }
Posted by: Guest on September-28-2020

Browse Popular Code Answers by Language