Spaces:
Running
Running
Download app/Http/Middleware/TrafficMiddleware.php from lisatthu35/ewa: direct link, hf CLI and curl.
- Browser
- Download file 587 Bytes
-
https://huggingface.co/spaces/lisatthu35/ewa/resolve/main/app/Http/Middleware/TrafficMiddleware.php
- Command line
-
hf download hf://spaces/lisatthu35/ewa/app/Http/Middleware/TrafficMiddleware.php
-
curl -L -o TrafficMiddleware.php https://huggingface.co/spaces/lisatthu35/ewa/resolve/main/app/Http/Middleware/TrafficMiddleware.php
587 Bytes
| namespace App\Http\Middleware; | |
| use App\Services\ComicServices; | |
| use Closure; | |
| use Illuminate\Http\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| class TrafficMiddleware | |
| { | |
| public function handle($request, Closure $next) | |
| { | |
| $comicServices = app()->make(ComicServices::class); | |
| $comic_code = $request['comic_code']; | |
| if($comic_code){ | |
| $entity = $comicServices->findByComicCode($comic_code); | |
| if($entity){ | |
| ++$entity->total_view; | |
| $entity->save(); | |
| } | |
| } | |
| return $next($request); | |
| } | |
| } | |