【问题标题】:Using Auth with table name other than users laravel将 Auth 与用户 laravel 以外的表名一起使用
【发布时间】:2016-09-13 00:45:26
【问题描述】:

我正在使用Auth 对用户进行身份验证。但使用 users 以外的表。 每当我使用这个控制器功能时。它显示表users 不存在。

public function authenticate(Request $request)
 {
    $input=$request->all();
    $password=$input['password'];
    $name=$input['name'];

    if (Auth::attempt(['Name' => $name, 'Password' => $password]) ){
        return redirect()->intended('/quiz/home');
}   else 
  {
        return view('quiz.login')->with('message','Error logging in!');
    }
}

【问题讨论】:

  • 您可以更改config/auth.php文件中的表名。

标签: php laravel authentication laravel-5


【解决方案1】:

here你有答案

// in the config/auth.php chage
'model' => 'App\User',
'table' => 'users',
// to...
'model' => 'App\Administrator',
'table' => 'administrators',

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 2021-05-17
    • 2013-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多