사용자의 새 등록 세부 정보를 추가하려고합니다. 사용자의 LASTNAME을 입력합니다. 하지만 내 데이터베이스에 삽입하는 데 문제가 있습니다. 이는 오는 오류가 최대Laravel 5.3 : 사용자 등록을위한 추가 사용자 정보를 추가 할 수 없습니다.
ERROR : 이것은 내 데이터베이스 마이그레이션 파일이
QueryException in Connection.php line 761: SQLSTATE[HY000]: General error: 1364 Field 'f_lastname' doesn't have a default value (SQL: insert into
users
(name
,password
,updated_at
,created_at
) values (chu, [email protected], 111, 2016-10-12 06:55:33, 2016-10-12 06:55:33))
입니다
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('f_lastname');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
user.php $ 채울 수있는 코드
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'f_lastname', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
및 등록 정보 r.php 검증 섹션
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255|unique:users',
'f_lastname' => 'required|max:255|unique:users',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'f_lastname' => $data['f_lastname'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
내가 본 튜토리얼의 대부분은 laravel 5.2이었다. 나는 laravel 5.3을 사용하면서 막 새로 왔습니다. 도움이되는 사람들을 감사하십시오!
가능한 중복 : 1364 필드 'display \ _name'에는 기본값이 없습니다.] (http://stackoverflow.com/questions/18751291/mysql-error-1364-field-display-name-doesnt-have-default-value) –