app/Http/Controllers/PostsController.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()
    {
        if(Auth::user()->admin)
        {
            $posts = Post::all();
        }
        else
        {
            $user_id = Auth::id();
            $posts = Post::where('user_id', $user_id)->get();
        }
        return view('admin.posts.index')->with('posts', $posts);
    }
public function index ( ) { if ( Auth :: user ( ) -> admin ) { $ posts = Post :: all ( ) ; } else { $ user_id = Auth :: id ( ) ; $ posts = Post :: where ( 'user_id' , $ user_id ) -> get ( ) ; } return view ( 'admin.posts.index' ) -> with ( 'posts' , $ posts ) ; }
Display a listing of the resource.
Display a listing of the resource .