I am implementing Laravel 5.3 Notifications at the moment which is working very nice.
At the moment I am using \'email\' as a notifications channel but I want to add
Hackish solution. But tried and tested on a MongoDB connection.
What needs to be modified;
Notifiable
traitDatabaseNotification
modelHasNotifications
traitDatabaseNotificationCollection
.Again this is useful for a non-mysql connectionNotifiable
TraitCopy the contents from Illuminate\Notifications\Notifiable
and create a new file in your custom path...say App\Overrides\Notifications\Notifiable
.
Your file will feature two changes...the namespace and you have to load the RoutesNotifications
trait since we are not copying it over.
DatabaseNotification
modelFollow the same procedure as above and copy the contents of the Illuminate\Notifications\DatabaseNotification
file to the custom path that we created above...App\Overrides\Notification\DatabaseNotification
This is a standard Eloquent model and the connection change actually happens here
As of this point this should work if you are on a mysql connection.
To try this out change the Notifiable
trait on the user model to use App\Overrides\Notifications\Notifiable
. The notifications will use the connection you specified.
Users of MongoDB will have to take extra steps since the most popular driver I know of does not yet support MorphMany relations which are put to use for Laravel notifications.
Since that is not the asked question we leave it at that :-)