Laravel身份验证系统-表不匹配


Laravel Authentication system- Tables do not match

我试图理解一个错误:SQLSTATE[42S22]:找不到列:1054"where clause"中的未知列"username"(SQL:从users中选择*,其中username=hi@hi.hi限制1)尝试登录时

我的"用户"表:id电子邮件密码名称admin created_at updated_at1.go@go.go$2y$10$1R/21A3C32nwkjtEgDFcyuMc2D4AtgeFnTh1ygLEcQl。。。go 1 2014-11-01 21:04:33 2014-11-01 22:04:332.hi@hi.hi$2-$10$Akb9BoLWrOcQT0KFee7vvujtrzkberRQnUDCuCXepeAd。。。hi 0 2014-11-02 16:15:47 2014-11-02 15:47

我的表单在视图中(正确显示)

@extends('login_c')
@section('loginform')
<?= '<span style="color:red">' .
Session::get('login_error') . '</span>' ?>
{{ Form::open() }}
{{ Form::label('email', 'Email address: ') }}
{{ Form::text('email', Input::old('email')) }}
<br>
{{ Form::label('password', 'Password: ') }}
{{ Form::password('password') }}
<br>
{{ Form::submit('Login!') }}
{{ Form::close() }}

@stop

问题是,我之前在注册时指定了密码,我不明白为什么会出现"无法登录"或SQL注入错误。

oute::get('registration', function()
{
return View::make('registration');
});
Route::post('registration', array('before' => 'csrf',
function()
{
    $rules = array(
    'email' => 'required|email|unique:users',
    'password' => 'required|same:password_confirm',
    'name' => 'required'
    );
    $validation = Validator::make(Input::all(), $rules);
    if ($validation->fails())
    {
        return Redirect::to('registration')->withErrors
        ($validation)->withInput();
    }
    $user = new User;
    $user->email = Input::get('email');
    $user->password = Hash::make(Input::get('password'));
    $user->name = Input::get('name');
    $user->admin = Input::get('admin') ? 1 : 0;
    if ($user->save())
    {
        Auth::loginUsingId($user->id);
        return Redirect::to('profile');
    }
    return Redirect::to('registration')->withInput();
}));
Route::get('profile', function()
{
if (Auth::check())
{
return 'Welcome! You have been authorized!';
}
else
{
return 'Please <a href="login">Login</a>';
}
});
Route::get('login', function()
{
return View::make('login');
});
Route::post('login', function()
{
$user = array(
'name' => Input::get('email'),
'password' => Input::get('password')
);
if (Auth::attempt($user))
{
return Redirect::to('profile');
}
return Redirect::to('login')->with('login_error',
'Could not log in.');
});
Route::get('secured', array('before' => 'auth', function()
{
return 'This is a secured page!';
}));

我的注册表格:(对不起,我没有发布我的完整视图,因为它不相关,我确信错误在表格和/或用户模型中。

{{ Form::open() }}
{{ Form::label('email', 'Email address: ') }}
{{ Form::text('email', Input::old('email')) }}
<br>
{{ Form::label('password', 'Password: ') }}
{{ Form::password('password') }}
<br>
{{ Form::label('password_confirm',
'Retype Password: ') }}
{{ Form::password('password_confirm') }}
<br>
{{ Form::label('name', 'Name: ') }}
{{ Form::text('name', Input::old('name')) }}
<br>
{{ Form::label('admin', 'Admin?: ') }}
{{ Form::checkbox('admin','true',
Input::old('admin')) }}
<br>
{{ Form::submit('Register!') }}
{{ Form::close() }}

@stop

我应该如何更改我的用户模型?为什么保存错误的密码?

尝试更改

$user = array(
'name' => Input::get('email'),
'password' => Input::get('password')
);

$user = array(
'email' => Input::get('email'), // You're using email to log in users, not name in your form
'password' => Input::get('password')
);