41 lines
988 B
PHP
41 lines
988 B
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Deal;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
use NotificationChannels\WebPush\WebPushChannel;
|
|
use NotificationChannels\WebPush\WebPushMessage;
|
|
|
|
class NewDealNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public function __construct(private readonly Deal $deal)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return [WebPushChannel::class];
|
|
}
|
|
|
|
public function toWebPush($notifiable, $notification): WebPushMessage
|
|
{
|
|
return (new WebPushMessage)
|
|
->title("New deal from {$this->deal->broker->name}")
|
|
->body("Check out this deal: {$this->deal->title}")
|
|
->action('View deal', route('explore', ['show' => $this->deal->id]));
|
|
}
|
|
}
|