PHP code example of binafy / laravel-user-monitoring
1. Go to this page and download the library: Download binafy/laravel-user-monitoring library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
'user' => [
/*
* User model.
*/
'model' => 'App\Models\User',
/*
* Foreign Key column name.
*/
'foreign_key' => 'user_id',
/*
* Users table name.
*/
'table' => 'users',
/*
* The correct guard.
*/
'guard' => 'web',
/*
* If you are using uuid or ulid you can change it for the type of foreign_key.
*
* When you are using ulid or uuid, you need to add related traits into the models.
*/
'foreign_key_type' => 'id', // uuid, ulid, id
],
'user' => [
...
/*
* If you are using uuid or ulid you can change it for the type of foreign_key.
*
* When you are using ulid or uuid, you need to add related traits into the models.
*/
'foreign_key_type' => 'uuid', // uuid, ulid, id
],
'visit_monitoring' => [
/*
* You can specify pages not to be monitored.
*/
'except_pages' => [
'home',
'admin/dashboard',
],
],
'visit_monitoring' => [
...
/*
* If you want to delete visit rows after some days, you can change this to 360,
* but if you don't like to delete rows you can change it to 0.
*
* For this feature you need Task-Scheduling => https://laravel.com/docs/10.x/scheduling
*/
'delete_days' => 10,
],
namespace App\Console;
...
use Binafy\LaravelUserMonitoring\Commands\RemoveVisitMonitoringRecordsCommand;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
{
$schedule->command(RemoveVisitMonitoringRecordsCommand::class)->hourly();
}
}
'visit_monitoring' => [
...
/*
* If you want to disable visit monitoring, you can change it to false.
*/
'turn_on' => true,
...
]
'visit_monitoring' => [
...
/*
* If you want to disable visit monitoring in Ajax mode, set it to false.
*/
'ajax_requests' => true,
...
],
namespace App\Models;
use Binafy\LaravelUserMonitoring\Traits\Actionable;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use Actionable;
}
'action_monitoring' => [
...
/*
* Monitor actions.
*
* You can set true/false for monitor actions like (store, update, and ...).
*/
'on_store' => false,
'on_update' => true,
'on_destroy' => true,
'on_read' => true,
'on_restore' => false,
'on_replicate' => false,
],
'authentication_monitoring' => [
...
/*
* You can set true/false for monitor login or logout.
*/
'on_login' => true,
'on_logout' => true,
],