您好我一直在研究Laravel框架,但无法让这个auth驱动程序工作!返回:
未处理的例外
Message:
Uninitialized string offset: 0
Location:
C:\wamp\www\site\laravel\auth\drivers\eloquent.php on line 39
我有一个登录控制器:
class Login_Controller extends Base_Controller {
public $restful = true;
public function post_index()
{
$username = Input::get('username');
$password = Input::get('password');
if ( Auth::attempt($username, $password) )
{
return Redirect::to('home');
}
else
{
return Redirect::to('login')->with('login_errors', true);
}
}
public function get_index() {
return View::make('page.login');
}
}
我有'username' => 'username',
在行名称
的auth.php中还有其他人遇到过这个吗?
问候
菲尔
答案 0 :(得分:0)
好的发现了,需要通过数组将凭证传递给attempt方法:
<?php
class Login_Controller extends Base_Controller {
public $restful = true;
public function post_index()
{
$username = Input::get('username');
$password = Input::get('password');
if ( Auth::attempt( array( 'username' => $username, 'password' => $password ) ) )
{
return Redirect::to('home');
}
else
{
return Redirect::to('login')->with('login_errors', true);
}
}
public function get_index() {
return View::make('page.login');
}
}