UserMiddleware.php 563 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. class UserMiddleware
  5. {
  6. /**
  7. * Handle an incoming request.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @param \Closure $next
  11. * @return mixed
  12. */
  13. public function handle($request, Closure $next)
  14. {
  15. if (Auth::check() && (isClient() || isFreelancer()) && !Auth::user()->banned) {
  16. return $next($request);
  17. }
  18. else{
  19. session(['link' => url()->current()]);
  20. return redirect()->route('user.login');
  21. }
  22. }
  23. }