PHP code example of laravel-notification-channels / webpush
1. Go to this page and download the library: Download laravel-notification-channels/webpush 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/ */
laravel-notification-channels / webpush example snippets
use NotificationChannels\WebPush\HasPushSubscriptions;
class User extends Model
{
use HasPushSubscriptions;
}
use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\WebPushMessage;
use NotificationChannels\WebPush\WebPushChannel;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [WebPushChannel::class];
}
public function toWebPush($notifiable, $notification)
{
return (new WebPushMessage)
->title('Approved!')
->icon('/approved-icon.png')
->body('Your account was approved!')
->action('View account', 'view_account')
->options(['TTL' => 1000]);
// ->data(['id' => $notification->id])
// ->badge()
// ->dir()
// ->image()
// ->lang()
// ->renotify()
// ->