Laravel Auth复制电子邮件

I'm using Laravel Auth to allow people to sign in.

Now I have a database in which people can exist multiple times ( for newer events )

So i'm wondering if it's possible to adjust the Auth Query to check for the latest email addresses, So fetch the email and password combination with the highest ID in the db

I don't seem to find the Query anywhere in the Illuminate Structure.. Am i looking in the wrong place here?

Class guard {

Seems to have the functionality of logging people in. Thank you!

You can by overriding the Auth driver.

To create a custom driver: 1. Create a new class that implements UserProviderInterface 2. Register your auth driver in app/start/global.php add the following:

Auth::extend('auth.mydriver', function($app)
{
    return new MyApp\Extensions\MyAuthDriver;
});
  1. Tell config to look for your driver in app/config/auth.php and change 'driver' => 'auth.mydriver',

Now Laravel uses your implementation of Auth. to get started I would copy the original code and change the methods you want to give a custom implementation

EDIT:

If you look at how attempt work it calls retrieveByCredentials if normal validation fails. If you want to override the way Guard you'll have to create your own Guard class and use instead of default one (app/config/app.php)

/**
     * Attempt to authenticate a user using the given credentials.
     *
     * @param  array  $credentials
     * @param  bool   $remember
     * @param  bool   $login
     * @return bool
     */
    public function attempt(array $credentials = array(), $remember = false, $login = true)
    {
        $this->fireAttemptEvent($credentials, $remember, $login);
        $this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
        // If an implementation of UserInterface was returned, we'll ask the provider
        // to validate the user against the given credentials, and if they are in
        // fact valid we'll log the users into the application and return true.
        if ($this->hasValidCredentials($user, $credentials))
        {
            if ($login) $this->login($user, $remember);
            return true;
        }
        return false;
    }