dev-master
9999999-devStatistical Package for a site
MIT
The Requires
by Hakim AIT TAYEB
Statistical Package for a site
Statistical Package for a site, (*1)
This package use the Agent.php class for package : jenssegers/agent, (*2)
Install the package with composer, (*3)
$ composer require athakim/stats dev-master
Then add the service provider to your config/app.php:, (*4)
Athakim\Stats\StatsServiceProvider::class,
Add the aliase to your config/app.php, (*5)
'Stats' => Athakim\Stats\Facades\Stats::class,
Add the visitors middleware to your app/Http/Kernel.php, (*6)
protected $routeMiddleware = [ ... 'visitors' => \Athakim\Stats\Middleware\VisitorsMiddleware::class, ];
Run the vendor:publish command to publish the package config, views and migrations to your app's directories:, (*7)
php artisan vendor:publish
Run your migrations:, (*8)
php artisan migrate
To begin we must first enable the filter, adding middleware visitors has your route group to record the visits and visitors:, (*9)
Route::group(['middleware' => ['web','visitors']], function () { Route::get('/', function () { ... # Your code }); ... });
As soon as you install and enable it, package 'Stats' will start storing all information you tell it to, then you can in your application use the Stats Facade to access everything. Here are some of the methods and relatioships available: ```$, (*10)
$nb_visits_in_year = Stats::getVisitsOfYear('21/01/2016')->count();, (*11)
$nb_visits_in_month = Stats::getVisitsOfMonth('21/01/2016')->count();, (*12)
$nb_visitors_in_day = Stats::getVisitorsOfDay('21/01/2016')->count();, (*13)
$visits_in_year = Stats::getVisitorsOfYear('21/01/2016'); ..., (*14)
$visitors = Stats::getAllVisitors();, (*15)
$pages = Stats::getAllPages();, (*16)
$nb = Stats::visitors(); .... ```, (*17)
MIT, (*18)
Statistical Package for a site
MIT