Search code examples
laraveleloquentlaravel-spark

Array to string conversion when using routeNotificationForDatabase


I've wrote a custom model without any relations to the database that uses the Notifiable trait. To support Database notifications I've added the method routeNotificationForDatabase() to this class as follows:

public function routeNotificationForDatabase()
{
    return new Notification();
}

However, this results into the following error. So obviously i'm doing something wrong. Could anybody point me in the right direction for this?

Illuminate\Database\QueryException : Array to string conversion (SQL: insert into notifications (id, type, data, read_at, updated_at, created_at) values (783ee870-cd52-4a2e-bdeb-fd89ca2aee11, App\Notifications\SystemMessage, WARNING! example.com is currently down., , 2018-04-28 18:53:35, 2018-04-28 18:53:35))

Stack Trace:

1 ErrorException::("Array to string conversion") /Users/xxx/sites/xxx/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php : 101

2 PDOStatement::bindValue(["WARNING! example.com is currently down."]) /Users/xxx/sites/xxx/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php : 101

Thank you in advance.

EDIT: Solved this by using the toSpark() channel for notifications instead of toDatabase(). I didn't realize that spark has a slightly different notifications model.


Solution

  • I've solved this by using the toSpark() channel for notifications instead of toDatabase(). I didn't realize that spark has a slightly different notifications model.