| Package Data | |
|---|---|
| Maintainer Username: | cassiobueno90 |
| Maintainer Contact: | admin@jonesboard.de (Jones) |
| Package Create Date: | 2017-07-13 |
| Package Last Update: | 2017-07-26 |
| Language: | PHP |
| License: | Unknown |
| Last Refreshed: | 2025-11-04 15:07:22 |
| Package Statistics | |
|---|---|
| Total Downloads: | 27 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 0 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
#Laravel 4 VisitorLog
A package for Laravel 4 to log all visitors
If anyone has any ideas on how to make this framework agnostic, please contact me or open a pull request.
##Installation
Add cassiobueno90/visitor-log as a requirement to composer.json:
{
...
"require": {
...
"cassiobueno90/visitor-log": "dev-master"
...
},
}
Update composer:
$ php composer.phar update
Add the provider to your app/config/app.php:
'providers' => array(
...
'Cassiobueno90\VisitorLog\VisitorLogServiceProvider',
),
Add the alias to your app/config/app.php:
'aliases' => array(
...
'Visitor' => 'Cassiobueno90\VisitorLog\Visitor',
),
Publish migration:
$ php artisan migrate --package=cassiobueno90/visitor-log
(Optional) Publish package config:
$ php artisan config:publish cassiobueno90/visitor-log
##Configuration
onlinetime: The time (in minutes) while a visitor is still savedusermodel: Set this to the Auth Provider you're using:
Laravel: Visitor-Log will try to get the User with Laravel's Auth ClassSentry: Visitor-Log will try to get the User with Sentryignore: This is an array of pages that will be ignored by Visitor-Log. Example "admin/online"##The Visitor Class The Visitor Class is an Eloquent Class but has a few extra methods, which will be explained here.
static isOnline($id): Will check whether the user with $id is onlinestatic getCurrent(): Will get the current Visitor (based on their sid)static clear(): Buggy!! This removes all old visitors from the Database. You normally don't need to call this as this happens on every request.static loggedIn(): Will get all logged in Usersstatic guests(): Will get all guestsstatic findUser($id): Will get the User provided by $id (if online)static findIp($ip): Will get all visitors with $ip
isUser(): Checks whether this visitor is a UserisGuest(): Checks whether this visitor is a GuestThere are a few methods that wraps the specific Useragent method:
is_browser(): Checks whether this visitor uses a browseris_robot(): Checks whether this visitor is a botis_mobile(): Checks whether this visitor uses a mobile clientis_referral(): Checks whether this visitor is a referralThe Visitor Class also provides some attributes:
sid: A random String which is used to identicate the visitorip: The IP of the visitorpage: The Page where the visitor isuseragent: The useragent of the visitoruser: The UserID of the visitorcreated_at, updated_at)agent: Returns the useragent Instance used for this visitoragents: Returns the modified Agentstring (eg Opera 12.16)platform: Returns the operating Systembrowser: Returns the Browser which is usedversion: Returns the Browser version which is usedrobot: Returns the Botname which is browsing your sitemobile: Returns the mobile which is usedreferrer: Returns the referrer##What's with an "Who's online page"?
It's really easy to add one by yourself but Visitor-Log provides you already a very simple one: simply add @include("visitor-log::online") to your blade template where you want. And the best: It's ready to look nice with bootstrap