DEV Community

Discussion on: Creating Your First Blog With TALL - Part Seven

Collapse
 
nayi10 profile image
Alhassan Kamil

Hey @kidnrks!

Thanks for reading. Actually, there are several ways you can do that:

  1. 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.
  2. 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.
  3. 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.