40 lines
956 B
PHP
40 lines
956 B
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Filament\Notifications\Notification as FilamentNotification;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class BroadcastNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public function __construct(
|
|
protected array $payload
|
|
) {
|
|
$this->payload = $payload;
|
|
}
|
|
|
|
public function via($notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
public function toDatabase($notifiable): array
|
|
{
|
|
$notification = FilamentNotification::make()
|
|
->title($this->payload['title'])
|
|
->body($this->payload['body']);
|
|
|
|
if (! empty($this->payload['action'])) {
|
|
$notification->actions($this->payload['action']);
|
|
}
|
|
|
|
return $notification->getDatabaseMessage();
|
|
}
|
|
}
|