dizel/log-users-access

1.0.0 2017-11-14 13:16 UTC

README

Package for Laravel 5.5 User actions are saved in Mongo DB. Daily summary possible to save in MySQL.

Instataltion

  • Run "composer require dizel/log-users-access"
  • Add service providers in config/app.php:
   'providers' => [
   
        DiZeL\LogUsersAccess\ServiceProvider::class,
        Jenssegers\Mongodb\MongodbServiceProvider::class,
  • Run php artisan vendor:publish --provider="DiZeL\LogUsersAccess\ServiceProvider"
  • Run "composer update"
  • Add connetion to Mongo DB in config/database.php:
    'mongodb' => [
        'driver'   => 'mongodb',
        'host'     => env('DB_HOST_MDB', 'localhost'),
        'port'     => env('DB_PORT_MDB', 27017),
        'database' => env('DB_DATABASE_MDB'),
        'username' => env('DB_USERNAME_MDB'),
        'password' => env('DB_PASSWORD_MDB'),
        'options'  => [
            'database' => 'admin' // sets the authentication database required by mongo 3
        ]
    ],
  • Add new constant for Mongo DB in .env:
DB_HOST_MDB=127.0.0.1
DB_PORT_MDB=27017
DB_DATABASE_MDB=testpack
DB_USERNAME_MDB=
DB_PASSWORD_MDB=
  • Run php artisan migrate
  • Run php artisan db:seed --class=LogSummariesTableSeeder
  • Run php artisan db:seed --class=LogUsersTableSeeder
  • Add new command in app/Console/Kernel.php:
    protected $commands = [
        //
        \DiZeL\LogUsersAccess\Console\Commands\SaveLogSummary::class,

Using

Routes
Add to log
  • In controllers
DiZeL\LogUsersAccess\Helpers\LogUserAccess::add();
  • To save errors in app/Exceptions/Handler.php:
    public function render($request, Exception $exception)
    {
        DiZeL\LogUsersAccess\Helpers\LogUserAccess::add($exception);
Save in MySQL

Run command "php artisan logsummary:save"