PHP code example of xcoorp / laravel-webpush-notifications

1. Go to this page and download the library: Download xcoorp/laravel-webpush-notifications 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/ */

    

xcoorp / laravel-webpush-notifications example snippets


class InvoicePaidNotification extends Notification
{
    // Trigger a specific notification event
    public function toWebPush($notifiable)
    {
        return (new WebPushMessage)
                ->title('Approved!')
                ->body('Your account was approved!')
                ->action('View account', 'view_account')
                ->options(['TTL' => 1000]);
    }
}

use NotificationChannels\WebPush\WebPushChannel;

public function via($notifiable)
{
    return [
        WebPushChannel::class
    ]
}
`bash
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider"
`bash
php artisan migrate
`bash
php artisan webpush-notifications:vapid