PHP code example of geisi / laravel-db-session-helper
1. Go to this page and download the library: Download geisi/laravel-db-session-helper 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/ */
geisi / laravel-db-session-helper example snippets
//User.php
use Illuminate\Foundation\Auth\User as Authenticatable;
use Geisi\LaravelDbSessionHelper\Traits\HasDatabaseSessions
class User extends Authenticatable
{
use HasDatabaseSessions;
// ...
}
//Query all online users
\App\Models\User::isOnline()->get();
//Query all offline users
\App\Models\User::isOffline()->get();
//Get user online state
var_dump($user->is_online);
// true or false
//Get user last login date
var_dump($user->last_login);
// Carbon instance
bash
php artisan vendor:publish --provider="Geisi\LaravelDbSessionHelper\LaravelDbSessionHelperServiceProvider"