php - Laravel 5.0 show logged in guests and registered users -


i attempting add function site shows number of logged in guests , registered users(displaying names of registered users can figure out part). presently, have read need change /config/session.php file 'driver' use database instead of file ('driver' => env('session_driver', 'database'),). found article uses sentry accomplish (http://laravel.io/forum/03-03-2014-sentry-3-users-online), however, prefer without requiring third party files. have, nonetheless, used information starting point utilizing model session.

as issues, first off, unable session start saving in database 'sessions' table after modifying session.php, creating table , migrating it. still saving in files in /storage/framework/session/ (i can still log in , display session information using session::all()).

mysql> select * sessions; empty set (0.00 sec) 

second issue, don't know how create session if 1 not exist given in file, there no way create (if opens site , thus, guest) nor unregister user when log out (remove logged-in status user_id seen guest).

here current onlineuser.php file:

<?php namespace app;  use illuminate\database\eloquent\model; // use sentry; use session; use auth;  class onlineuser extends model {      /**      * {@inheritdoc}      */     public $table = 'sessions';      /**      * {@inheritdoc}      */     public $timestamps = false;      /**      * returns guest users.      *      * @param  \illuminate\database\eloquent\builder  $query      * @return \illuminate\database\eloquent\builder      */     public function scopeguests($query)     {         return $query->wherenull('user_id');     }      /**      * returns registered users.      *      * @param  \illuminate\database\eloquent\builder  $query      * @return \illuminate\database\eloquent\builder      */     public function scoperegistered($query)     {         return $query->wherenotnull('user_id')->with('user');     }      /**      * updates session of current user.      *      * @param  \illuminate\database\eloquent\builder  $query      * @return \illuminate\database\eloquent\builder      */     public function scopeupdatecurrent($query)     {         return $query->where('id', session::getid())->update(array(             'user_id' => !empty(auth::user()) ? auth::user()->id : null         ));     }      /**      * returns user belongs entry.      *      * @return \cartalyst\sentry\users\eloquentuser      */     public function user()     {         return $this->belongsto('\app\user');         //return $this->belongsto('cartalyst\sentry\users\eloquentuser'); # sentry 3         // return $this->belongsto('cartalyst\sentry\users\eloquent\user'); # sentry 2     }  } 

if has information assist me in solving these problems, obliged. if need more information, let me know , respond when able to.

thanks.

in response first issue laravel still save session in /storage/framework/session/

if updated session.php file follows:

env('session_driver', 'database')

make sure update .env file

session_driver=database


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -