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()
    {
        $posts = Post::
            with('user')
                ->wherePublic(true)
                ->when(Auth::id(), function (Builder $query, $userId) {
                    $query->orWhere('posts.user_id', $userId);
                })
                ->latest()
                ->get()
            ;
        return view('posts.index', [
            'posts' => $posts,
        ]);
    }
public function index ( ) { $ posts = Post :: with ( 'user' ) -> wherePublic ( true ) -> when ( Auth :: id ( ) , function ( Builder $ query , $ userId ) { $ query -> orWhere ( 'posts.user_id' , $ userId ) ; } ) -> latest ( ) -> get ( ) ; return view ( 'posts.index' , [ 'posts' => $ posts , ] ) ; }
Display a listing of the resource.
Display a listing of the resource .