“字段列表”中的未知列“ user_id”(SQL:插入notifications
(id
,type
,data
,read_at
,user_id
,updated_at
,created_at
)
我要进行迁移的地方是这样的表:
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
我没有user_id,并且查看通知(id,类型,数据)。其完全不同。
我的NotificationClass
public function via($notifiable)
{
return ['mail', 'database'];
}
public function toArray($notifiable)
{
return [
"message" => "this is a test",
"url" => "go somewhere else",
];
}
不知道什么会影响插入。
答案 0 :(得分:0)
我认为您需要将user_id列添加到通知表。这样,通知便知道将其分配给的用户。如果没有此列,则无法将通知分配给用户。