<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pschocke / laravel-notification-settings example snippets
$model->saveNotificationSettingFromRequest($request);
$model->sendNotification(new OrderReceivedNotification($order); // this model will receive the notification on all channels he has configured
return [
/**
* The Settings the user can choose if he wants to be notified at a given event
*/
'settings' => [
/**
* The default model. Add more if you want different settings for different models
*/
'default' => [
/**
* The default events for this model. Add a new array with the notitication key to have different settings for different notification channels
*/
'default' => [
'event1' => 'description1',
'event2' => 'description2',
],
],
],
'verificationNotification' => pschocke\NotificationSettings\Notifications\NotificationSettingVerificationNotification::class,
'handler' => [
'mail' => pschocke\NotificationSettings\Handler\MailHandler::class,
],
'driver' => [
'mail' => [
'verification' => [
'enabled' => true,
'method' => 'link',
],
],
],
];
$myModel->saveNotificationSetting([
'type' => 'mail', // the key of the handler
'meta' => [ // everything configured in the handler as ;
$myModel->sendNotification(new OrderShippedNotification($notification), 'orderShipped'); // the second parameter is the setting name.
namspace App\NotificationSettingHandler;
use pschocke\NotificationSettings\Models\NotificationSetting;
use pschocke\NotificationSettings\Handler\Handler;
use pschocke\NotificationSettings\Handler\HandlerInterface;
class SlackHandler extends Handler implements HandlerInterface
{
protected $request = [
'webhook' => [' return $methodName === 'routeNotificationForSlack'; // the method name to route the notification
}
public function getSend(NotificationSetting $notificationSetting) // returns what is needed to route the notification
{
return $notificationSetting->meta['webhook'];
}
}