douhoulei4706 2014-04-28 21:44
浏览 90
已采纳

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

I'm trying to do a basic authentication, and I have many problems, the main one is this

enter image description here

This error when I send the form and try to authenticate

blade

{{ 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

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

Model

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'
                        );
}

Controller

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');
        }

    }
}
}

Auth

'driver' => 'database',
'model' => 'Usuario',
'table' => 'Usuario',

please, how can I fix it?

  • 写回答

1条回答 默认 最新

  • doutan3040 2014-04-28 21:56
    关注

    Because attemp should be attempt:

    if(Auth::attemp($userdata))
    

    Should be:

    if(Auth::attempt($userdata))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题