2017 © Pedro Peláez
 

library stats

Statistical Package for a site

image

athakim/stats

Statistical Package for a site

  • Sunday, March 20, 2016
  • by athakim
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

stats

Statistical Package for a site, (*1)

Requirements


  • PHP 5.4 or above
  • Laravel 5.2 or above

Installation


This package use the Agent.php class for package : jenssegers/agent, (*2)

Step 1 : Install the package

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,
    ];

Step 2: Publish the package files

Run the vendor:publish command to publish the package config, views and migrations to your app's directories:, (*7)

php artisan vendor:publish

Step 3: Update your database

Run your migrations:, (*8)

php artisan migrate

Usage

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)

Get the number of visits within a year

$nb_visits_in_year = Stats::getVisitsOfYear('21/01/2016')->count();, (*11)

Get the number of visits within a month

$nb_visits_in_month = Stats::getVisitsOfMonth('21/01/2016')->count();, (*12)

Get the number of visits in a day

$nb_visitors_in_day = Stats::getVisitorsOfDay('21/01/2016')->count();, (*13)

you can also get collections

$visits_in_year = Stats::getVisitorsOfYear('21/01/2016'); ..., (*14)

get all visitors collection

$visitors = Stats::getAllVisitors();, (*15)

get all pages visited collection

$pages = Stats::getAllPages();, (*16)

get number of visitors

$nb = Stats::visitors(); .... ```, (*17)

Licence

MIT, (*18)

The Versions

20/03 2016

dev-master

9999999-dev

Statistical Package for a site

  Sources   Download

MIT

The Requires

 

by Hakim AIT TAYEB

18/01 2016

0.1.0

0.1.0.0

Statistical Package for a site

  Sources   Download

MIT

by Hakim AIT TAYEB