call_user_func_array()期望参数1是有效的回调,类' Illuminate \ Auth \ Guard'没有方法'尝试' - 在Laravel的Auth

时间:2014-04-28 21:44:27

标签: php authentication laravel laravel-4

我试图进行基本身份验证,我遇到很多问题,主要是这个

enter image description here

发送表单并尝试进行身份验证时出现此错误

叶片

{{ Form::open(array('url' => 'usuario')) }}

                    <input type="text" class="text"  id="email" name="email" placeholder="Correo" {{(Input::old('email')) ? 'value ="'. Input::old('email').'"' : '' }}>
                    <p>{{ $errors->first('email') }}</p>
                    <input type="text" class="text"  id="password" name="password" placeholder="Contraseña" >
                    <p>{{ $errors->first('password') }}</p>


                {{ Form::submit('Ingresar', array('class' => 'bg1')) }}
{{ Form::close() }}

路线

Route::post('usuario', array('as' => 'usuario', 'uses' => 'UsuarioController@doLogin'));

模型

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class Usuario extends Eloquent implements UserInterface, RemindableInterface{
protected $table = 'Usuario';
protected $primaryKey = 'idUsuario';
protected $hidden = array('Contrasena');
protected $fillable = array(
                        'Nombre',
                        'Apellido',
                        'Tipo',
                        'Contrasena',
                        'Correo',
                        'Fono',
                        'Foto'
                        );
}

控制器

class UsuarioController extends BaseController{

public function doLogin(){
    $rules = array(
                    'email' => 'required|email',
                    'password' => 'required'
                    );
    $validator = Validator::make(Input::all(), $rules);
    if($validator->fails()){
        return Redirect::to('usuario')->withErrors($validator)->withInput(Input::except('password'));
    }else{

        $userdata = array(
            'Correo' => Input::get('email'),
            'Password' => Input::get('password')
            );

        if(Auth::attemp($userdata)){
            return View::make('hello');
        }else{
            return Redirect::to('usuario');
        }

    }
}
}

验证

'driver' => 'database',
'model' => 'Usuario',
'table' => 'Usuario',
请问,我该如何解决?

1 个答案:

答案 0 :(得分:5)

因为attemp应为attempt

if(Auth::attemp($userdata))

应该是:

if(Auth::attempt($userdata))