laravel中的Auth类如何知道哪个表要比较数据? 以及要检查哪些字段?

I wanted to implement my own auth system in laravel rather then go with the default , so i was going through THIS tutorial. it uses laravel-4 so obviously some of the code will change. There is below snippet of code where the user is being authenticated , see below:

// app/controllers/HomeController.php<


public function doLogin() {
// validate the info, create rules for the inputs
$rules = array(
    'email'    => 'required|email', // make sure the email is an actual email
    'password' => 'required|alphaNum|min:3' // password can only be alphanumeric and has to be greater than 3 characters
);

// run the validation rules on the inputs from the form
$validator = Validator::make(Input::all(), $rules);

// if the validator fails, redirect back to the form
if ($validator->fails()) {
    return Redirect::to('login')
        ->withErrors($validator) // send back all errors to the login form
        ->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form
} else {

        // create our user data for the authentication
        $userdata = array(
            'email'     => Input::get('email'),
            'password'  => Input::get('password')
        );

        // attempt to do the login
        if (Auth::attempt($userdata)) {

            // validation successful!
            // redirect them to the secure section or whatever
            // return Redirect::to('secure');
            // for now we'll just echo success (even though echoing in a controller is bad)
            echo 'SUCCESS!';

        } else {        

            // validation not successful, send back to form 
            return Redirect::to('login');

        }
    }
}

I don't quite understand the below line of code:

if (Auth::attempt($userdata)) {

How does the Auth class know which table to look for and compare the data ?? Also how does it know which fields to compare against ?? This is a bit confusing . can somebody please explain this ??

The INTRO of auth class was quite helpful for me to understand how the Auth class works , but i still did't quite get an answer to my above questions.

Laravel knows that all, because column names (email and password) and table name (users) are hardcoded and Laravel uses these names by default.

In Laravel 5 you should set the auth table in the config/auth.php file in the following section:

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\UserModel::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

As you see, you can set DB's table or even the model.

As for auth field, by default there are name, email and password. If you want to use custom fields, you should redeclare standard methods in any Class that use Illuminate\Foundation\Auth\AuthenticatesUsers:

protected function credentials(Request $request)
{
    return $request->only($this->username(), 'password');
}

public function username()
{
    return 'email';
}

Laravel knows it via the config/auth.php, where you should have something like this in Laravel 4:

/*
    |--------------------------------------------------------------------------
    | Authentication Model
    |--------------------------------------------------------------------------
    |
    | When using the "Eloquent" authentication driver, we need to know which
    | Eloquent model should be used to retrieve your users. Of course, it
    | is often just the "User" model but you may use whatever you like.
    |
    */

    'model' => 'User',

    /*
    |--------------------------------------------------------------------------
    | Authentication Table
    |--------------------------------------------------------------------------
    |
    | When using the "Database" authentication driver, we need to know which
    | table should be used to retrieve your users. We have chosen a basic
    | default value but you may easily change it to any table you like.
    |
    */

    'table' => 'users',

The username is hardcoded, but, if you need, you should be able to change by adding this method to your User model:

public function username()
{
    return 'username';
}