app/Http/Controllers/PostController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $title = '';
        if(request('category')){
            $category = Category::firstWhere('slug', request('category'));
            $title    = ' in ' . $category->name;
        }
        if(request('author')){
            $author = User::firstWhere('username', request('author'));
            $title = ' by ' . $author->name;
        }
        return view('post',[
            "title" => "All Posts" . $title,
            'active' => 'posts',
            "posts" => Post::latest()->where('status', '=', 'published')->filter(request(['search', 'category','author']))
            ->paginate(7)->withQueryString()
        ]);
    }
public function index ( ) { $ title = '' ; if ( request ( 'category' ) ) { $ category = Category :: firstWhere ( 'slug' , request ( 'category' ) ) ; $ title = ' in ' . $ category -> name ; } if ( request ( 'author' ) ) { $ author = User :: firstWhere ( 'username' , request ( 'author' ) ) ; $ title = ' by ' . $ author -> name ; } return view ( 'post' , [ " title " => " All Posts " . $ title , 'active' => 'posts' , " posts " => Post :: latest ( ) -> where ( 'status' , '=' , 'published' ) -> filter ( request ( [ 'search' , 'category' , 'author' ] ) ) -> paginate ( 7 ) -> withQueryString ( ) ] ) ; }
Display a listing of the resource.
Display a listing of the resource .