Adding view count error

Posted 2 years ago by Eco012390

My error

SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update `posts` set `0` = 1, `updated_at` = 2016-05-09 01:58:18 where `id` = 4)

My Controller show method

public function show(Request $request, $id)
    {
       // IF HAS SESSION DONT UPDATE VIEW COUNT

          if(Session::has('viewed')){
            dd('you got session so you cant update view count');
          }
      // ELSE ADD VIEW COUNT
          else{
            Post::where('id', $id)->update(['view_count' + 1]);
            Session::put('viewed');
          }

         $comments = Comment::where('blog_id', $id)->with('user')->orderBy('created_at', 'ASC')->paginate(4);
         $blogs = Post::where('id', $id)->with('user')->first();
         return view('frontend.dashboard.blog-single' ,compact('blogs','comments'));
    }

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.