晚上好。我在我的用户模型和迁移中添加了一个布尔字段“privacy_ok”。
迁移文件
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name',100)->nullable();
$table->string('last_name',100)->nullable();
$table->string('email');
$table->string('password');
$table->boolean('privacy_ok')->default(0);
$table->text('permissions')->nullable();
$table->timestamp('last_login')->nullable();
$table->timestamps();
$table->engine = 'InnoDB';
$table->unique('email');
});
应用\用户.php
class User extends Authenticatable
{
use Notifiable;
protected $fillable = [
'first_name','last_name','email', 'password', 'privacy_ok'
];
....
当我尝试注册我的用户时,会跳过新字段。
$user = Sentinel::register($request->all());
我注意到,如果我导致错误(例如重复的电子邮件地址……),INSERT 查询会显示“privacy_ok”字段。
有没有办法解决这个问题?
我是否必须使用 User::create 并将其“转换”为 Cartalyst Sentinel 对象才能继续进行所有其他操作(例如激活)?
谢谢
编辑
我在这里找到了一些信息 Laravel Cartalyst Sentinel - 向用户表添加用户名列(正确的方法是什么)
现在我有一个新文件 App\Models\Cartalyst\User.php,但是当我将它添加到 cartalyst 配置文件 ( config/cartalyst.sentinel.php ) 时,我收到一个错误。
'users' => [
// 'model' => 'Cartalyst\Sentinel\Users\EloquentUser',
'model' => 'App\Models\Cartalyst\User',
],
无法声明类 User,因为该名称已在使用中
当然,即使我将用户更改为 Lorem,用户也在那里。这不是命名问题。
已解决 我忘了在新类的标题中声明命名空间!:(