duandu1377
2015-06-18 13:16
浏览 68
已采纳

Laravel 5 Auth ::由自定义控制器尝试

Am getting the below error, when I try to implement Auth::attempt()

The controller I have looks like

 Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\Models\User given

The controller I have looks like

<?php namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Contracts\Auth\Authenticable;
use Illuminate\Auth\UserInterface;



class AdminAjaxController extends Controller {
    public function getLogin()
    {
        $data = array('email' => Input::get('email'), 'password' =>Input::get('password'));
        Auth::attempt($data);
    }
}

图片转代码服务由CSDN问答提供 功能建议

当我尝试实现Auth :: attempt() 时出现以下错误 n

我看起来的控制器

 传递给Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()的参数1必须是Illuminate \ Contracts \ Auth \ Authenticatable的实例 ,App \ Models \ User的实例给出
   
 
 

我看起来的控制器

 &lt;?php 命名空间App \ Http \ Controllers \ Admin; 
 
use App \ Http \ Controllers \ Controller; 
use App \ Models \ User; 
use Illuminate \ Support \ Facades \ Auth; 
use Illuminate \ Contracts \ Auth \ Authenticable; \  nuse Illuminate \ Auth \ UserInterface; 
 
 
 
class AdminAjaxController扩展Controller {
公共函数getLogin()
 {
 $ data = array('email'=&gt; Input :: get('email')  ),'password'=&gt;输入:: get('password')); 
 Auth :: attempt($ data); 
} 
} 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • duanshang9426 2015-06-19 11:50
    最佳回答

    The error gone by changing the driver in Auth.php from Eloquent to Database

    评论
    解决 无用
    打赏 举报