vito/app/Notifications/AbstractNotification.php
2025-03-12 13:31:10 +01:00

44 lines
1.1 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\NotificationChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Queue\SerializesModels;
abstract class AbstractNotification extends Notification implements NotificationInterface, ShouldQueue
{
use Queueable, SerializesModels;
public function via(object $notifiable): string
{
/** @var NotificationChannel $notifiable */
return $notifiable->provider()::class;
}
public function toEmail(object $notifiable): MailMessage
{
return (new MailMessage)
->subject('Notification')
->line($this->rawText());
}
public function toSlack(object $notifiable): string
{
return $this->rawText();
}
public function toDiscord(object $notifiable): string
{
return $this->rawText();
}
public function toTelegram(object $notifiable): string
{
return $this->rawText();
}
}