use Illuminate\Contracts\Auth\Guard; public function index(Guard $auth) { $user = $auth->user(); return view('dashboard', compact('user')); }
use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Request; public function login(Guard $auth, Request $request) { $credentials = $request->only('email', 'password'); if ($auth->attempt($credentials)) { return redirect()->intended('dashboard'); } else { return redirect()->route('login') ->withErrors(['email' => 'Wrong email or password']); } }This code logs a user in using the `attempt` method on the `Guard` instance injected into the controller, and redirects them to the dashboard if successful. If the login fails, it redirects back to the login form with an error message. The Illuminate\Contracts\Auth package library is part of the Illuminate authentication system, which is a component of the Laravel framework. It defines the interfaces and contracts that other authentication components rely on, such as the Guard and UserProvider interfaces.