/** * @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; }
<?php /** * @var $user \App\User */ if (!isset($user)) { $user = \App\Helpers\CommonHelper::getCurrentUser(); } $virtual_user = \App\Helpers\VirtualUserHelper::user(); ?> @if($virtual_user) <!--button class="btn btn-default">{{ $virtual_user->name }}</button--> @endif @if(!$user) <a href="/auth/login">Авторизация</a> | <a href="/auth/register">Регистрация</a> @endif <?php if (!$user) { return; } $open_orders = $user->orderedProducts()->get(); $open_orders_count_str = $open_orders->count() . ' товаров на ' . $user->getAmountOpenOrders() . ' руб.'; $deferred_products = $user->deferredProducts()->get(); ?> @if( count($deferred_products) ) <div class="btn-group"> <div class="btn-group"> <a href="/deferred" class="btn btn-warning">