lundi 22 avril 2019

How add new parameter to check in login Laravel

In login controller I override the credentials method, like this:

protected function credentials(Request $request)
{
    $credentials = $request->only($this->username(), 'password');
    $credentials['status'] = User::STATUS_ACTIVE;

    return $credentials;
}

And this work pretty fine. But when a try to add a parameter which is not a column of the Users table I don't know how check there. Some like this:

protected function credentials(Request $request)
{
    $credentials = $request->only($this->username(), 'password');
    $credentials['status'] = User::STATUS_ACTIVE;
    $credentials['customer-status'] = Customer::STATUS_ACTIVE;

    return $credentials;
}

Where can I check if value is correct? I tried to make a event listener to Attempting login, but don't work. Someone can help me?!

My idea is make a eloquent query to return count of customers actives, if are more then 1 customer-status for this user is true.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire