IsUnbanned.php 667 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use Auth;
  5. class IsUnbanned
  6. {
  7. public function handle($request, Closure $next)
  8. {
  9. if (auth()->check() && auth()->user()->banned) {
  10. $redirect_to = "";
  11. if(auth()->user()->user_type == 'admin' || auth()->user()->user_type == 'staff'){
  12. $redirect_to = "login";
  13. }else{
  14. $redirect_to = "user.login";
  15. }
  16. auth()->logout();
  17. $message = translate("You are banned");
  18. flash($message);
  19. return redirect()->route($redirect_to);
  20. }
  21. return $next($request);
  22. }
  23. }