BanUserCheck.php 766 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Illuminate\Contracts\Auth\Guard;
  4. use Closure;
  5. class BanUserCheck
  6. {
  7. /**
  8. * The Guard implementation.
  9. *
  10. * @var Guard
  11. */
  12. protected $auth;
  13. /**
  14. * Create a new filter instance.
  15. *
  16. * @param Guard $auth
  17. * @return void
  18. */
  19. public function __construct(Guard $auth)
  20. {
  21. $this->auth = $auth;
  22. }
  23. /**
  24. * Handle an incoming request.
  25. *
  26. * @param \Illuminate\Http\Request $request
  27. * @param \Closure $next
  28. * @return mixed
  29. */
  30. public function handle($request, Closure $next)
  31. {
  32. if($this->auth->check() && $this->auth->user()->status === -1){
  33. abort(403);
  34. }
  35. return $next($request);
  36. }
  37. }