PHP code example of evtray / notifier

1. Go to this page and download the library: Download evtray/notifier 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/ */

    

evtray / notifier example snippets


use SchoolAid\Notifier\Facades\Notifier;
use SchoolAid\Notifier\Payloads\NoteCreated\NoteCreatedPayload;

$payload = NoteCreatedPayload::builder()
    ->note(noteId: 123, schoolId: 45, title: 'Field trip', fromName: 'School Office',
           content: '<p>...</p>', important: false)
    ->channels(['push', 'email'])
    ->recipient(studentId: 678)
    ->pushUser(userId: 9, language: 'es', devices: ['fcm-token-1'])
    ->emailUser(userId: 9, email: '[email protected]')
    ->metadata(userId: 1)
    ->build();                    // throws InvalidPayloadException on contract violation

Notifier::publish($payload);      // inline (sync) produce
Notifier::publishAsync($payload); // queued produce
bash
php artisan vendor:publish --tag=notifier-config      # config/notifier.php
php artisan vendor:publish --tag=notifier-migrations  # optional, to customize the table