PHP code example of edwink / filament-user-activity

1. Go to this page and download the library: Download edwink/filament-user-activity 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/ */

    

edwink / filament-user-activity example snippets


return [
    "table" => [
        "name" => env("FILAMENT_USER_ACTIVITY_TABLE_NAME", "user_activities"),
        "retention-days" => env("FILAMENT_USER_ACTIVITY_RETENTION_DAYS", 60),
        'active-users' => [
            'timeframe-selection' => [
                15 => '15 Minutes',
                30 => '30 Minutes',
                60 => 'One hour',
                120 => '2 Hours',
                1440 => '24 hours',
            ],
        ],
    ]
];

    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array<int, class-string|string>
     */
    protected $middleware = [
        ...
        \Edwink\FilamentUserActivity\Http\Middleware\RecordUserActivity::class,
    ];


use Edwink\FilamentUserActivity\Traits\UserActivityTrait;
...

class User extends Authenticatable
{
    use UserActivityTrait;
    ...
}

use Edwink\FilamentUserActivity\FilamentUserActivityPlugin;

...
public function panel(Panel $panel): Panel
{
    return $panel
        ...
        ->plugins([
           FilamentUserActivityPlugin::make()
        ])
        ...
}
...
bash
php artisan vendor:publish --tag="filament-user-activity-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="filament-user-activity-config"
bash
php artisan vendor:publish --tag="filament-user-activity-views"
bash
php artisan filament-user-activity:truncate-activities-table