我有注册表单,当我尝试将数据插入数据库密码列时,它们是基础字段获取空白值,当我尝试从php artisan tinker命令插入我的记录时,其工作方式密码列获取其值
以下是我的代码
RegisterController.php
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
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 = '/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, [
'user_firstname' => 'required|string|max:255',
'user_lastname' => 'required|string|max:255',
'user_phone' => 'required|numeric|unique:users',
'email' => 'required|string|email|max:255|unique:users',
'username' => 'required|string|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
//dd($data);
return User::create([
'user_firstname' => $data['user_firstname'],
'user_lastname' => $data['user_lastname'],
'user_phone' => $data['user_phone'],
'email' => $data['email'],
'username' => $data['username'],
'password' => Hash::make($data['password']),
]);
}
}
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
@if ($errors->has('password'))
<span class="invalid-feedback">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
我只是创建用户对象并使用laravel elequant将行插入数据库之前已经工作但是现在所有的数据库列都在表单中输入了除密码字段之外的值,不知道什么问题请帮帮我