Thanks for reading. Actually, there are several ways you can do that:
The simplest, just modify the posts table and add a new column view to it. Any time the details page of a post is viewed, you update the views column with increment.
Create a separate post_views table and record page views there with the post ID/slug. You can even link it to the posts table using one-to-many relationship foreign key constraints.
Lastly, you can also use the Laravel Visits plugin for more fine-grained control of visits.
Note: For methods 1-2 you may need to ensure visits are unique by using, say, cookies.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
can you teach us how to add post view count
Hey @kidnrks!
Thanks for reading. Actually, there are several ways you can do that:
view
to it. Any time the details page of a post is viewed, you update theviews
column with increment.post_views
table and record page views there with the post ID/slug. You can even link it to the posts table using one-to-many relationship foreign key constraints.Note: For methods 1-2 you may need to ensure visits are unique by using, say, cookies.