Kanvas provides a notification service. Similar to laravel, it's an information messaging system used for sending PushNotifications, Email, SmS, Real time notification and any other type of channel you decide to add. Notifications are located at
You have to define a class that extends from Canvas\Notifications\Notification and implements NotificationInterfase.
You can use the
message function to define the message that this notification will send using the following methods
You will always have the objects toUser and fromUser, so that you know who is sending the notification and who is receiving it.
For distributed apps, it's recommended not to store files locally and use 3rd party services like S3. With kanvas we recommend using our template management interface. Basically we allow you to save volts templates for your app on the DB for easier access.
In order to create a template you need to add it to the Kanvas email_template table using Phalcon volt template languague.
In order to use Kanvas templates, you must call the generate function, pass the name of the template and provide an array of the variables used within the template.
Notifications are sent to users, so you will need to add NotifiableTrait to your User model. By default Kanvas Users model already has it implemented.
As you can tell we didn't run the toAction function since it internally will do so for us.
If we need to notify more than one user we can use all.
Where users is a user array list.
We can queue a notification by just setting the property useQueue
This will use the Kanvas queue notification and run async.