0
I’ve tried everything, but nothing works. I’m pretty sure the reason is that the default name of Attempt "password" does not match the name of the passwordhash column,
<?php
namespace App\Http\Controllers\admin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class LoginController extends Controller
{
public function login(Request $request){
$data = $request->all();
if(Auth::guard('admin')->attempt(['login'=>$data['loginadmin'],'password'=>$data['passadmin'],'isadmin'=>1]))
{
return 'logou';
}else{
return 'naao logou';
}
}
}
My Model User:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends \Illuminate\Foundation\Auth\User
{
protected $table = "tb_user";
protected $fillable = [
'login',
'passwordhash',
'fullname',
'cpf'
];
public $timestamps = false;
}
I think I’ll need to change this pattern from Attempt "password" to passwordhash, but I have no idea how to do it. Or it might even be another solution and I don’t which.
From now on I’d like to thank anyone who helps me.
Voce has tried to change the array key of
passsword
forpasswordhash
in the methodattempt
?– RFL
worst I ever tried, but when I do it gives an error q the password attribute is null, IE, it is mandatory to use this way
– Wendel Luiz