我正在为用户制作注册页面。在那里我创建了mysql db,称为注册的网页和必要的laravel文件,包括controller和web.php。但问题是,当我通过填写注册页面中的表单来发送数据时,只有“电子邮件”和“密码”。字段存储在mysql数据库中。其他人填写默认' NULL'。在这里,我插入了所有文件的图片,这将有助于检查问题。
signup.blade.php
Pagecontroller.php
web.php
signup form
signup form filled with information
problematic db only email and password filled with data others are NULL
User.php user model
mysql db
答案 0 :(得分:1)
将您的属性添加到fillable()
模型中的User
数组:
protected $fillable = [
'email', 'username', 'first_name','last_name','phone_number','address','password'
];
答案 1 :(得分:0)
在App\User.php
添加:
protected $fillable = [
'first_name',
'last_name',
'address',
'email',
'phone_number',
'username',
'password'
];
如果您在creating
和updating
方法添加用户观察者,那么也会很好:
if ($user->isDirty('password'))
{
$user->password = Hash::make($user->password);
}
当然,在观察者的顶部包括use Hash
了解观察员:LINK