I am trying to make Authentication on the Employee table but it always gives me false
I do not what should I change to make auth apply on the Employee table.
Is auth->attempt go and check the database or not
This is Employee controller
<?php
namespace AppHttpControllers;
use AppModelsEmployee;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
class EmployeeController extends Controller
{
public function login()
{
return view("Employee.login");
}
public function check(Request $request)
{
$data = $request->validate([
'email' => 'required|email|max:200',
'password' => 'required|string',
]);
$emp = $request->only('email', 'password');
if (Auth::guard('Employee')->attempt($emp) {
dd($request);
} else {
return "error";
}
}
I make some change to the auth.php and I add guards of Employee but it also did not work
This is auth.php
<?php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'employees' => [
'driver' => 'eloquent',
'model' => AppModelsEmployee::class,
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'Employee',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
'Employee' => [
'driver' => 'session',
'provider' => 'employees',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => AppModelsUser::class,
],
'employees' => [
'driver' => 'eloquent',
'model' => AppModelsEmployee::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
'employees' => [
'driver' => 'eloquent',
'model' => AppModelsEmployee::class,
],
],
'password_timeout' => 10800,
];
question from:
https://stackoverflow.com/questions/65939659/custom-authentication-in-laravel-8