Download the PHP package niladam/laravel-visits without Composer
On this page you can find all versions of the php package niladam/laravel-visits. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download niladam/laravel-visits
More information about niladam/laravel-visits
Files in niladam/laravel-visits
Package laravel-visits
Short Description A simple package to record visits on your eloquent models or pages
License MIT
Homepage https://github.com/niladam/laravel-visits
Informations about the package laravel-visits
Laravel Visits - simple drop-in package that records visits.
This is a small package that allows you to easily record visits to your models and / or custom URLs, either by using the included middleware or by using the provided helpers.
The package stores the visits in a separate table, so it doesn't bloat your existing tables.
This package makes use of PHP's inet_ntop and inet_pton functions to store the IP addresses in a binary format, reducing your database size.
The package tries to keep the visits table simple, with only the following data being stored:
- The IP address of the visitor
- An optional user ID, if the visitor is authenticated
- The platform (
desktop
,phone
,tablet
,robot
orother
) (makes use of jenssegers/agent) - The referer (if any)
- The entity that's being visited
- The URL that's being visited (if not an entity) - by removing the current app URL from the string.
Installation
You can install the package via composer:
Publish the migration with:
Publish the config file with:
Run the migrations:
`
Prepare your model, implementing the CanHaveVisits
interface and the HasVisits
trait.
Here's an example:
Add the included middleware to your route:
That's it. Your visits will be recorded automatically.
Manually recording visits:
The package provides the following helper to help you record your visits.
The recording will happen async, by default and therefore not slow down your application.
In order to manually record a visit use the recordVisit
helper:
You can also record visits using the lvVisit
helper which looks like this:
Retrieving the visits:
Retrieving visits for a specific platform/type:
The package comes with scopes for all the platform, so you can limit the results to a specific platform.
Retrieving the IP address (since it's being stored as binary):
Customise
The package comes with a config file that allows you to customise the jobs, middleware and the default user model.
The config file is published to config/laravel-visits.php
and looks like this:
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Madalin Tache
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-visits with dependencies
illuminate/support Version ^8.0 || ^9.0 || ^10.0
illuminate/config Version ^8.0 || ^9.0 || ^10.0
illuminate/database Version ^8.0 || ^9.27 || ^10.0
jenssegers/agent Version ^2.6.3