PHP code example of eightcedars / filament-inactivity-guard

1. Go to this page and download the library: Download eightcedars/filament-inactivity-guard 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/ */

    

eightcedars / filament-inactivity-guard example snippets


return [
     /**
     * Determine if the plugin is enabled
     */
    'enabled' => true,

    /**
     * How long to wait before an idle session is considered inactive.
     * This value must be in seconds
     */
    'inactivity_timeout' => Carbon::SECONDS_PER_MINUTE * 14,

    /**
     * How long to show an inactive session notice before logging the user out.
     * This value must be in seconds
     *
     * Set this to null or 0 to disable the notice and log out immediately a user's session becomes inactive
     */
    'notice_timeout' => 60,

    /**
     * This package watches for a list of browser events to determine if a user is still active.
     * You may customise as desired.
     *
     * Ensure that the list is not empty
     */
    'interaction_events' => ['mousemove', 'keydown', 'click', 'scroll'],
];

use EightCedars\FilamentInactivityGuard\FilamentInactivityGuardPlugin;

$panel
    ...
    ->plugin(FilamentInactivityGuardPlugin::make())
    ...

use EightCedars\FilamentInactivityGuard\FilamentInactivityGuardPlugin;use Illuminate\Support\Carbon;$panel
    ...
    ->plugin(
        FilamentInactivityGuardPlugin::make()
            ->inactiveAfter(5*Carbon::SECONDS_PER_MINUTE)
            ->showNoticeFor(1* Carbon::SECONDS_PER_MINUTE)
            // Or set to null to logout immediately after inactivity
            ->showNoticeFor(null)
            
            ->enabled(!app()->isLocal())
            ->keepActiveOn(['change', 'select', 'mousemove'], mergeWithDefaults: true),
    )
    ...
bash
php artisan vendor:publish --tag="filament-inactivity-guard-config"
bash
php artisan vendor:publish --tag="filament-inactivity-guard-translations"

bash
php artisan vendor:publish --tag="filament-inactivity-guard-views"