Added native os notifications

This commit is contained in:
2026-07-01 22:11:24 +10:00
parent d1b50e2f1a
commit 84379baf6a
19 changed files with 213 additions and 39 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Notifications;
use App\Models\Notification as NotificationModel;
use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\WebPushChannel;
use NotificationChannels\WebPush\WebPushMessage;
class PushNotification extends Notification
{
public function __construct(
protected NotificationModel $notification
) {}
public function via($notifiable): array
{
return [WebPushChannel::class];
}
public function toWebPush($notifiable, $notification): WebPushMessage
{
return (new WebPushMessage)
->title($this->notification->title)
->body($this->notification->body)
->icon( '/img/app_icons/icon-192.png')
->data([
'url' => $this->notification->url,
'notification_id' => $this->notification->id,
]);
}
}