laravel role based authentication code example
Example: role acces login in laravel
public function authenticate(Request $request)
{
$request->validate([
'email' => 'required|string|email',
'password' => 'required|string',
]);
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
return redirect('/');
}
return redirect('login')->with('error', 'Opps! You have entered invalid credentials');
}