PHP code example of evanschleret / laravel-user-presence

1. Go to this page and download the library: Download evanschleret/laravel-user-presence 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/ */

    

evanschleret / laravel-user-presence example snippets


use EvanSchleret\LaravelUserPresence\Traits\HasUserPresence;

class User extends Authenticatable
{
    use HasUserPresence;
}

// app/Http/Kernel.php
protected $middlewareGroups = [
    'web' => [
        // ...
        \EvanSchleret\LaravelUserPresence\Http\Middleware\UpdateLastSeen::class,
    ],
];


// config/user-presence.php
return [
    'online_threshold' => 300,  // in seconds
    'idle_threshold' => 600,     // in seconds
    'guard' => 'web', // or 'api' / 'sanctum' if using API authentication
];
bash
php artisan vendor:publish --provider="EvanSchleret\LaravelUserPresence\Providers\LaravelUserPresenceServiceProvider"
bash
php artisan vendor:publish --provider="EvanSchleret\LaravelUserPresence\Providers\LaravelUserPresenceServiceProvider" --tag="migrations"
bash
php artisan migrate