About this project

Laravisit is a Composer-managed Laravel package designed to add visit tracking and page view analytics to any Eloquent model in a clean, fluent interface. Installation is done via Composer with `composer require coderflexx/laravisit`, followed by publishing the configuration file and running migrations to set up the required database tables. To use the package, a model must import and apply the `HasVisits` trait while implementing the `CanVisit` interface. Once configured, developers can log visits using the `visit()` method on a model instance, with optional chaining methods to attach IP address, session ID, custom data arrays, and authenticated user associations. Visit aggregation supports multiple time-based intervals including hourly, daily, weekly, monthly, yearly, and custom Carbon-based intervals. The default behavior deduplicates visits per day per user. For retrieving analytics, the package provides query scopes such as `withTotalVisitCount()`, `popularAllTime()`, `popularToday()`, `popularLastDays($days)`, `popularThisWeek()`, `popularLastWeek()`, `popularThisMonth()`, `popularLastMonth()`, `popularThisYear()`, `popularLastYear()`, and `popularBetween($from, $to)` to fetch ranked results across different date ranges. A visit presenter layer, powered by the laravel-presenter package, exposes decorated attributes like IP address and associated user details on visit records. The package includes PHPUnit tests runnable with `composer test` and is released under the MIT license.