laravel 5.5内置在身份验证数据库表引用位置

时间:2018-02-13 06:43:28

标签: database laravel authentication built-in

我在使用Laravel内置身份验证功能时遇到问题。作为默认的Laravel身份验证访问users表来检查/添加用户名和密码。我需要将其更改为student表。通常在模型中protected $table=student代码用于提及要使用的表。

有人能告诉我在内置身份验证功能中找到protected $table=代码或类似内容的位置吗?

第2部分 下面的代码是我的控制器中的代码,我将表单数据放入$data并验证并将其返回到我的商店函数中,但是我收到错误

  

类型错误:函数App \ Http \ Controllers \ StudentController :: store()的参数太少,0传递正好1个预期“

protected function validator(array $data)
 {
   $data = Request::all();
     return Validator::make($data, [
         'fname' => 'required|string|max:255',
         'lname' => 'required|string|max:255',
         'district' => 'required|string|max:255',
         'email' => 'required|string|email|max:255|unique:student',
         'password' => 'required|string|min:6|confirmed',
     ]);`
 }

public function store(array $data)
{
  return Student::create([
      'fname' => $data['fname'],
      'lname' => $data['lname'],
      'district' => $data['district'],
      'email' => $data['email'],
      'password' => bcrypt($data['password']),
    ]);

2 个答案:

答案 0 :(得分:0)

添加

protected $table=student;

User的{​​{1}}模型

app/User.php

更改

app/Http/Controllers/Auth/RegisterController.php

        'email' => 'required|email|max:255|unique:users',

答案 1 :(得分:0)

将其添加到App \ User.php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;
    protected $table = "users_old"; //your custom table

    ....
}