1Your middleware must return a Response object, or $next($request). As written,
2when not logged in or when $empl is empty, your middleware is just returning a
3string, not a redirect. Update your returns to:
4
5return route('login');
6to
7return redirect()->route('login');
8
9respectively.