1

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.

imadk
  • 51
  • 6
  • You are trying to call vendor\laravel\framework\src\Illuminate\Notifications\Notification.php method? – outman Apr 28 '18 at 22:04
  • 1
    @outman Thank you for your reply. I found out that spark has a slightly different set-up in their notifications model. So instead of using `toDatabase()` i have now turned to `toSpark()` which does exactly what I needed. – imadk Apr 29 '18 at 20:27

1 Answers1

1

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.

imadk
  • 51
  • 6