Reputation: 3605
My view count still increments even though I have session can any one tell what is wrong with my code?
if(! ( Session::get($id) == $id)){
Post::where('id', $id)->increment('view_count');
dd('added count');
Session::put('id', $id);
}
The id is the blog->id
Upvotes: 0
Views: 1238
Reputation: 563
Your code should be
if(! ( Session::get('id') == $id)){
Post::where('id', $id)->increment('view_count');
dd('added count');
Session::put('id', $id);
}
change Session::get($id)
to Session::get('id')
Upvotes: 1