You're doing the following:
However that won't work because...
attempt takes a username (eg: admin) and a plain text password (eg: 123). The user database stores the hashed password (eg: $2a$10$xbFFpiHRRv8y6e.6STPQxehcLwY8V9Lq/HUNjfbuCdHSe2PTLBcNy) which means you're passing the hashed password to attempt, which will always fail.
If you want to login a user by their ID (eg: 1) use loginUsingId:
Auth::loginUsingId(1);
If you want to login a user using a provided username and password use attempt, eg:
$username = 'admin';
$password = '123';
Auth::attempt(['username' => $username, 'password' => $password]);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.