我使用该php artisan notification:table命令user_id在通知迁移中创建了一个自定义列。如何设置自定义列的值user_id?
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->unsignedBigInteger('user_id');
$table->string('type');
$table->morphs('notifiable', 50);
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate("cascade");
});
在此功能中,我发送了通知,但引发了错误。user_id列没有默认值
public function saveUser($formdata)
{
$password = $formdata['password'];
$securePassword = Hash::make($password);
$user = User::create(array_merge($formdata, ['password' => $securePassword]));
$admin = User::where('type', 'admin')->first();
$letter = collect([
'title' => $user->name.' New User Registered in your Portal',
]);
Notification::send($admin, new DatabaseNotification($letter));
return $user;
}
请帮助我弄清楚如何设置该user_id值。
慕桂英4014372