czemu/laravel-simplestats

Simple statistics for Laravel.

1.1.0 2018-06-15 13:56 UTC

This package is auto-updated.

Last update: 2024-08-29 04:42:20 UTC


README

Simple statistics package for Laravel inspired by Simplestats for Kohana.

Requirements

  • PHP 7.1+
  • Laravel 5.5+

Installation

Install the package via composer:

composer require czemu/laravel-simplestats

If you're using Laravel >= 5.5, the package will register itself automatically.

Publish the migrations:

php artisan vendor:publish --provider='Czemu\Simplestats\SimplestatsServiceProvider' --tag="migrations"

Run the migrations:

php artisan migrate

You can also publish the config file:

php artisan vendor:publish --provider='Czemu\Simplestats\SimplestatsServiceProvider' --tag="config"

Usage

Update or create statistics for an item named "file" with id "1":

Simplestats::update('file', 1);

Update or create unique statistics (based on cookie) for an item named "print" with id "2":

Simplestats::update('print', 2, TRUE);

Get statistics for an item named "page" with id "3":

Simplestats::get('page', 3);

Get statistics for an item named "download" with id "4" on specified date:

Simplestats::get('download', 4, '2018-05-20');

Get statistics for an item named "click" with id "5" between specified date range:

Simplestats::get('download', 5, ['2018-05-01', '2018-05-15']);

License

The MIT License (MIT). Please see the LICENSE.md file for more information.