Always returning error when making login , even though the data is correct. I have already seen several topics about this error, but none have solved the problem.
CONTROLLER
public function cadastro(Request $request)
{
$dataForm = $request->all();
$dataForm['password'] = bcrypt($dataForm['password']);
$cliente = $this->cliente->create($dataForm);
}
public function login(Request $request)
{
$credentials = ['email' => $request->email, 'password' => $request->password];
if(Auth::guard('cliente')->attempt($credentials)) {
echo 'OK';
} else {
echo 'ERRO';
}
}
MODEL
class Cliente extends Authenticatable
{
protected $table = 'clientes';
protected $dates = ['created_at','updated_at'];
protected $fillable = ['nome', 'sobrenome', 'email', 'password'];
protected $hidden = ['password'];
}
AUTH
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'cliente' => [
'driver' => 'session',
'provider' => 'clientes',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'clientes' => [
'driver' => 'eloquent',
'model' => App\Cliente::class,
],
],
];
I am creating the table without migration , ie directly in the database:
CREATE TABLE clientes(id int auto_increment,
nome varchar(50),
sobrenome varchar(50),
email varchar(50),
password varchar(50),
created_at datetime,
updated_at datetime,
primary key(id));