Argument 1 passed to App\Http\Controllers\Auth\LoginController::attemptLogin() must be an instance of App\Http\Controllers\Auth\Request

Ray Coder picture Ray Coder · Jan 9, 2019 · Viewed 8.4k times · Source

I am adding 1 attribute for authentication, but it doesn't work. i'm not change anything except

adding this 2 method in my LoginController

protected function credentials(Request $request)
    {
        return $request->only($this->username(), 'password', 'division_id');
    }
/**
 * Attempt to log the user into the application.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return bool
 */


protected function attemptLogin(Request $request)
{
    $request->merge(['division_id' => '1']);
    return $this->guard()->attempt(
        $this->credentials($request), $request->filled('remember')
    );
}

I want to user login just exact division_id 1

Answer

Ismoil  Shifoev picture Ismoil Shifoev · Jan 9, 2019

import the request class with use \Illuminate\Http\Request; at the top of the LoginController.

That should fix it ;)