Exemplo n.º 1
0
 /**
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return
  */
 public function handle($request, Closure $next)
 {
     $virtual_user = \App\Helpers\VirtualUserHelper::user();
     $response = $next($request);
     if (!$virtual_user) {
         $virtual_user = \App\Models\VirtualUser::create(['last_ip' => $request->ip()]);
         $virtual_session = cookie(self::SESSION_VAR_NAME, $virtual_user->id);
         $response->withCookie($virtual_session);
     }
     return $response;
 }
Exemplo n.º 2
0
 public static function user()
 {
     $virtual_user_id = \Request::cookie(self::SESSION_VAR_NAME);
     return \App\Models\VirtualUser::find($virtual_user_id);
 }