laravel通知插入错误的表列

“字段列表”中的未知列“ user_id”(SQL:插入notificationsidtypedataread_atuser_idupdated_atcreated_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",];
}

不知道什么会影响插入。

liyinjie86 回答:laravel通知插入错误的表列

我认为您需要将user_id列添加到通知表。这样,通知便知道将其分配给的用户。如果没有此列,则无法将通知分配给用户。

本文链接:https://www.f2er.com/3168028.html

大家都在问