Session is not working properly
why is this not working properly?
I can still refresh a lot and the view_count still increases.
My controller
public function show(Request $request, $id)
{
if(!Session::get($id) == $id){
Post::where('id', $id)->increment('view_count');
Session::put($id, $id);
}
$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 suggest me something if there is a better and easier way. thank you!
Learn more about syntaxes ...
-
!Session::get($id) == $id probably you meant (! ( Session::get($id) == $id)) or more appropriately Session::get($id) != $id
-
Session::get($id) == $id doesn't make any sense, rather Session::get('id') == $id and Session::put('id' $id); do.
@d3xt3r did you mean Session::put('id' , $id);
Yes, missed a comma (,), bloody Monday :(
Please or to participate in this conversation.