Laravel Add Custom Conditions While Login
----------------------------------------------
Add custom condition while login in laravel.
I made it work by directly adding condition in AuthenticatesUsers trait
If you go inside the following folder
/vendor/laravel/framework/src/Illuminate/Foundation/Auth
and open the file AuthenticatesUsers.php
Once you open the file you can see protected function credentials(Request $request){}
method is this where you can add condition
Like.
/**
* Get the needed authorization credentials from the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
protected function credentials(Request $request)
{
$credentials = $request->only($this->username(), 'password');
$credentials = array_add($credentials, 'frontend_regsitered', '1');
return $credentials;
}
So add you can see i have added frontend_regsitered as 1 custom condition while login.