Download the PHP package douglasanpa/active-users without Composer
On this page you can find all versions of the php package douglasanpa/active-users. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download douglasanpa/active-users
More information about douglasanpa/active-users
Files in douglasanpa/active-users
Package active-users
Short Description A Laravel Package for easily retrieving a list of active users and guests that are currently online.
License MIT
Homepage https://github.com/joshrainwater/active-users
Informations about the package active-users
A Laravel Package for easily retrieving a list of active users and guests that are currently online.
This is a small, simple little package for seeing who's currently online.
Installation
Install via composer with:
Setup
Sessions and Database
For now, this package only supports the 'database' type for session storage. Open your .env file and change the session driver to database:
and also make sure to publish the default session table with:
Providers and Aliases
In order to use the Active class, reference the full vendor namespace, or just import the class at the top of the file that you want to use it in. Eg:
or
This package also includes a provider and alias to make things easier. To set those up properly, open config/app.php
and add this to your providers array:
and this to your aliases array:
Usage
Grabbing Most Recent Activities
Import the Active facade at the top and then do a simple query.
By default, the 'users' method will return users that have been active in the past 5 minutes. If you want to display a different timespan, use the following functions:
The functions listed above all return Eloquent Queries, so you can do anything with the results that would do with any other model:
Sorting Methods
There are a couple convenience methods for sorting results, as well:
Guests
You can also view online guests with all the same methods as users above:
Many thanks to thomastkim/laravel-online-users on which this is very heavily based.
License
This package is free software distributed under the terms of the MIT license.