Download app/Http/Middleware/UpdateUserActivity.php from pnacorp/magicai: direct link, hf CLI and curl.
- Browser
- Download file 634 Bytes
-
https://huggingface.co/pnacorp/magicai/resolve/main/app/Http/Middleware/UpdateUserActivity.php
- Command line
-
hf download hf://pnacorp/magicai/app/Http/Middleware/UpdateUserActivity.php
-
curl -L -o UpdateUserActivity.php https://huggingface.co/pnacorp/magicai/resolve/main/app/Http/Middleware/UpdateUserActivity.php
634 Bytes
| namespace App\Http\Middleware; | |
| use Closure; | |
| use Illuminate\Http\Request; | |
| use Illuminate\Support\Facades\Auth; | |
| use Illuminate\Support\Facades\Cache; | |
| class UpdateUserActivity | |
| { | |
| /** | |
| * Handle an incoming request. | |
| * | |
| * @param Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next | |
| */ | |
| public function handle($request, Closure $next) | |
| { | |
| if (Auth::check()) { | |
| $userId = Auth::id(); | |
| $expiresAt = now()->addMinutes(5); | |
| Cache::put('user-is-online-' . $userId, true, $expiresAt); | |
| } | |
| return $next($request); | |
| } | |
| } | |