Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 1.07 KB

File metadata and controls

61 lines (39 loc) · 1.07 KB

Laravel 5.3 - Laravel Users Online 2.0.x

Instalation

Add the new required package in your composer.json

"highideas/laravel-users-online": "^2.0"

Run composer update or php composer.phar update.

Or install directly via composer

composer require highideas/laravel-users-online

After composer command, add new service provider in config/app.php :

HighIdeas\UsersOnline\UsersOnlineServiceProvider::class,
HighIdeas\UsersOnline\Providers\UsersOnlineEventServiceProvider::class,

And add new middleware in app/Http/Kernel.php :

\HighIdeas\UsersOnline\Middleware\UsersOnline::class,

After this, add the trait in your model User in app/User.php:

class User extends Authenticatable
{
    use \HighIdeas\UsersOnline\Traits\UsersOnlineTrait;
...

For show the users online just use the method isOnline():

$user->isOnline();

// Or

$users = User::all();

foreach ($users as $user) {

    if ($user->isOnline()) {
        // show the user
    }
}

Finally run php artisan vendor:publish for add the namespaces