传递给Illuminate \ Auth \ Guard :: login()的参数1必须是laravel5.1

时间:2016-01-22 16:18:23

标签: authentication laravel-5.1

我正在为我的项目使用laravel 5.1。我正在尝试验证我的内置模型而不是laravel自己的用户模型。

My model name is Registration_Model
my table is registration
来自Laravel 5.1 multiple authentication

我做了他说的话。 auth.php文件是

     return [
'multi' => [
        'user' => [
        'driver' => 'eloquent',
        'model'  => App\User::class,
        'table'  => 'users'
    ],
    'registration' => [
        'driver' => 'eloquent',
        'model'  => App\Registration_Model::class, // Model Class
        'table'  => 'registration' // registration table
    ],
 ],
 'password' => [
       'email' => 'emails.password',
       'table' => 'password_resets',
       'expire' => 60,
  ]
 ];

我的route.php文件是

Route::resource('/', 'RegistrationController');
Route::get('register', function () {
    return view('project.register');
});
Route::post('route_register','RegistrationController@store');

// Authentication routes...
Route::get('auth/login', 'Auth\AuthRegistrationController@getLogin');
Route::post('auth/login', 'Auth\AuthRegistrationController@postLogin');
// Route::post('auth/login', 'Auth\AuthController@authenticate');
Route::get('auth/logout', 'Auth\AuthRegistrationController@getLogout');

// Registration routes...
Route::get('auth/register', 'Auth\AuthRegistrationController@getRegister');
Route::post('auth/register','Auth\AuthRegistrationController@postRegister');

和我的AuthRegistrationController.php文件是

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use Validator;
use App\Http\Requests\Request;
use Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use App\Http\Controllers\RegistrationController;
use App\Registration_Model;

class AuthRegistrationController extends Controller
{

    use AuthenticatesAndRegistersUsers, ThrottlesLogins;  

    public function __construct()
    {
        $this->middleware('guest', ['except' => 'getLogout']);
    }  

    protected function validator(array $data)
    {
        return Validator::make($data, [

            'email' => 'required|email|max:255|unique:registration',
            'password' => 'required|confirmed|min:3',
        ]);
    }

    protected function create(array $data)
    {
        return Registration_Model::create([

            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);
    }

    protected $redirectPath = 'register'; 
    protected $loginPath = '/auth/login';
}

我在尝试注册时收到错误消息。

  
      
  1. Guard.php第430行中的ErrorException:参数1传递给   Illuminate \ Auth \ Guard :: login()必须是。的实例   Illuminate \ Contracts \ Auth \ Authenticatable,实例   App \ Registration_Model给出。我在尝试登录时收到错误消息
  2.   
  3. EloquentUserProvider.php第110行中的ErrorException:参数1   传递给   Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()必须是   实例的Illuminate \ Contracts \ Auth \ Authenticatable实例   给出的App \ Registration_Model,调用   C:\ XAMPP \ htdocs中\ project_2016 \厂商\ laravel \框架\ SRC \照亮
  4.   

\验证\ Guard.php     在第390行并定义     我的Registration_Model在这里

<?php

    namespace App;

    use Illuminate\Database\Eloquent\Model;

    class Registration_Model extends Model
    {
         protected  $table = "registration";
        protected $primaryKey = "reg_id";

        protected $fillable = ['email','password'];
    }

0 个答案:

没有答案