CheckGateToken.php 816 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Illuminate\Http\Request;
  5. use App\Services\CallApiService;
  6. use App\Http\Controllers\Api\ApiController;
  7. class CheckGateToken
  8. {
  9. private $callApiService;
  10. public function __construct(CallApiService $callApiService)
  11. {
  12. $this->callApiService = $callApiService;
  13. }
  14. /**
  15. * Handle an incoming request.
  16. *
  17. * @param \Illuminate\Http\Request $request
  18. * @param \Closure $next
  19. * @return mixed
  20. */
  21. public function handle(Request $request, Closure $next)
  22. {
  23. // session()->put('GateToken.erp', 'duoICbFSNRRoxXoIaC0G');
  24. if (empty(session('GateToken'))) {
  25. $this->callApiService->setGateToken();
  26. }
  27. // dump(session('GateToken'));
  28. return $next($request);
  29. }
  30. }