PHP code example of djl997 / laravel-actor-is-active

1. Go to this page and download the library: Download djl997/laravel-actor-is-active 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/ */

    

djl997 / laravel-actor-is-active example snippets


    namespace App\Models;

    use Djl997\LaravelActorIsActive\Traits\IsOnlineTrait;

    class Actor {

        use IsOnlineTrait;

        // ..

    }
    

protected $middlewareGroups = [
    'web' => [
        // ..
        \Djl997\LaravelActorIsActive\Http\Middleware\IsOnline::class,
    ]
];

$model = Model::find(1);

$model->touchOnline();

$user = User::find(1);

$user->isOnline(); // returns true if user is online
$user->wasOnlineRecently(); // returns true if user was inline x minutes ago (by default 5-30 minutes, customizable via config)
$user->lastOnlineAt(); // returns Carbon object of last online timestamp
$user->getCacheActorOnlineKey(); // get the online cache key