1. Go to this page and download the library: Download novu/novu-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
novu / novu-laravel example snippets
return [
/*
|--------------------------------------------------------------------------
| Novu API Key
|--------------------------------------------------------------------------
|
| The Novu API key give you access to Novu's API. The "api_key" is
| typically used to make a request to the API.
|
*/
'api_key' => env('NOVU_API_KEY'),
/*
|--------------------------------------------------------------------------
| The Novu API Base URL.
|--------------------------------------------------------------------------
|
| The Novu API Base URL can be a self-hosted novu api or Novu's web cloud API
| typically used to make a request to Novu's service.
|
*/
'api_url' => env('NOVU_BASE_API_URL', 'https://api.novu.co/v1/'),
];
NOVU_API_KEY=xxxxxxxxxxxxx
use Novu\Laravel\Facades\Novu;
$response = Novu::triggerEvent([
'name' => '<WORKFLOW_TRIGGER_ID_FROM_DASHBOARD>',
'payload' => ['customVariables' => 'Hello'],
'to' => [
'subscriberId' => '<SUBSCRIBER_ID_FROM_DASHBOARD>',
'phone' => '07983887777'
]
])->toArray();
// or you can use the novu() helper function like so:
novu()->triggerEvent([
'name' => '<WORKFLOW_TRIGGER_ID_FROM_DASHBOARD>',
'payload' => ['customVariables' => 'Hello'],
'to' => [
'subscriberId' => '<SUBSCRIBER_ID_FROM_DASHBOARD>',
'phone' => '07983887777'
]
])->toArray();
use Novu\Laravel\Facades\Novu;
// Get all notifications
Novu::getNotifications()->toArray();
// Get all notifications with query parameters
$queryParams = [
'page' => 3
];
Novu::getNotifications($queryParams)->toArray();
// Get one notification
Novu::getNotification($notificationId)->toArray();
// Get notification stats
Novu::getNotificationStats()->toArray();
// Get Notification graph stats
Novu::getNotificationGraphStats()->toArray();
// Get Notification graph stats with query parameters
$queryParams = [
'days' => 5
];
Novu::getNotificationGraphStats($queryParams)->toArray();
use Novu\Laravel\Facades\Novu;
// Create Notification group
Novu::createNotificationGroup([
'name' => '<insert-name>'
]);
// Get Notification groups
Novu::getNotificationGroups()->toArray();
use Novu\Laravel\Facades\Novu;
// Get changes
Novu::getChanges();
// Get changes count
Novu::getChangesCount()->toArray();
// Apply changes
Novu::applyBulkChanges([
'changeIds' = [
'<insert-all-the-change-ids>'
]
])->toArray();
// Apply change
Novu::applyChange($changeId, []);
use Novu\Laravel\Facades\Novu;
// Get current environment
Novu::getCurrentEnvironment()->toArray();
// Create environment
Novu::createEnvironment([
'name' => '<insert-name>',
'parentId' => '<insert-parent-id>' // optional
])->toArray();
// Get environments
Novu::getEnvironments()->toArray();
// Update environment by id
Novu::updateEnvironment($envId, [
"name" => "name",
"identifier" => "identifier",
"parentId" => "parentId"
]);
// Get API KEYS
Novu::getEnvironmentsAPIKeys()->toArray();
// Regenerate API KEYS
$key = Novu::regenerateEnvironmentsAPIKeys()->toArray();
// Update Widget Settings
Novu::updateWidgetSettings([
'notificationCenterEncryption' => true
]);
use Novu\Laravel\Facades\Novu;
// Create feed
Novu::createFeed([
'name' => '<insert-name-for-feed>'
]);
// Get feeds
Novu::getFeeds()->toArray();
// Delete feed
Novu::deleteFeed();
use Novu\Laravel\Facades\Novu;
// Get messages
Novu::getMessages([
'page' => 1,
'channel' => ['<insert-channel>'],
]);
// Delete message
Novu::deleteMessage();
use Novu\Laravel\Facades\Novu;
// Get execution details
Novu::getExecutionDetails([
'notificationId' => '<insert-notification-id>',
'subscriberId' => '<insert-subscriber-id>'
])->toArray();
use Novu\Laravel\Facades\Novu;
// Create tenant
Novu::createTenant([
'identifier' => '<identifier>',
'name' => '<name>',
]);
// Get tenants
Novu::getTenants()->toArray();
use Novu\Laravel\Facades\Novu;
// Validate MX Record for Inbound Parse
Novu::validateMXRecordForInboundParse()->toArray();