Skip to main content
Back to packages
887 GitHub stars

cyrildewit/eloquent-viewable

View on GitHub

Description

This Laravel package allows you to associate views with Eloquent models.

Once installed you can do stuff like this:

// Return total views count
views($post)->count();
 
// Return total views count that have been made since 20 February 2017
views($post)->period(Period::since('2017-02-20'))->count();
 
// Return total views count that have been made between 2014 and 2016
views($post)->period(Period::create('2014', '2016'))->count();
 
// Return total unique views count (based on visitor cookie)
views($post)->unique()->count();
 
// Record a view
views($post)->record();
 
// Record a view with a cooldown
views($post)->cooldown(now()->addHours(2))->record();

Related Content on Laravel Daily

Video

Recent Courses on Laravel Daily

Marketing for Developers in 2026

7 lessons
52 min

Mobile Apps: React Native vs Flutter vs NativePHP?

8 lessons
55 min

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read