Laravel Add Custom Conditions While Login

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 


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


     * 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.


Categories: PHP Tags: #Laravel,

Newsletter Subcribe

Receive updates and latest news direct from our team. Simply enter your email.