使用 Laravel Auth 提交注册表时,我收到InvalidArgumentException Database connection [users] not configured. http://127.0.0.1:8000/register错误。我的 Laravel 版本是 6.17.1
.env 文件
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
Auth/RegisterController.php 文件
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:20'],
'surname' => ['required', 'string', 'max:30'],
'age' => ['required', 'integer', 'max:100'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users.email'],
'password' => ['required', 'string', 'min:6'],
'confirm' => ['required', 'string', 'same:password']
]);
}
}
白猪掌柜的
幕布斯6054654
慕桂英4014372
噜噜哒