Laravel 使用routeNotificationForDatabase时的数组到字符串转换
我已经编写了一个自定义模型,它与使用Laravel 使用routeNotificationForDatabase时的数组到字符串转换,laravel,eloquent,laravel-spark,Laravel,Eloquent,Laravel Spark,我已经编写了一个自定义模型,它与使用Notifiable特性的数据库没有任何关系。为了支持数据库通知,我将方法routeNotificationForDatabase()添加到此类中,如下所示: public function routeNotificationForDatabase() { return new Notification(); } 但是,这会导致以下错误。很明显我做错了什么。有人能给我指出正确的方向吗 Illumb\Database\QueryException:数组
Notifiable
特性的数据库没有任何关系。为了支持数据库通知,我将方法routeNotificationForDatabase()
添加到此类中,如下所示:
public function routeNotificationForDatabase()
{
return new Notification();
}
但是,这会导致以下错误。很明显我做错了什么。有人能给我指出正确的方向吗
Illumb\Database\QueryException:数组到字符串的转换(SQL:插入通知
(id
,类型
,数据
,读取时间
,更新时间
,创建时间
)值(783ee870-cd52-4a2e-bdeb-FD89CA2AE11,App\Notifications\SystemMessage,WARNING!example.com当前已关闭,2018-04-28 18:53:352018-04-28 18:53:35))
堆栈跟踪:
1 ErrorException::(“数组到字符串的转换”)
/Users/xxx/sites/xxx/vendor/doctor/dbal/lib/doctor/dbal/Driver/PDOStatement.php:101
2 PDOStatement::bindValue([“警告!example.com当前已关闭。”]))
/Users/xxx/sites/xxx/vendor/doctor/dbal/lib/doctor/dbal/Driver/PDOStatement.php:101
先谢谢你
编辑:通过使用
toSpark()
通知通道而不是toDatabase()
解决了这个问题。我没有意识到spark有一个稍微不同的通知模型。我通过使用toSpark()
通知通道而不是toDatabase()解决了这个问题
。我没有意识到spark的通知模型稍有不同。您正在尝试调用vendor\laravel\framework\src\light\notifications\notifications.php方法?@outman谢谢您的回复。我发现spark的通知模型的设置稍有不同。因此,不要使用toDatabase()
我现在转到了toSpark()
,它正是我所需要的。