From 64dd7466c26e9b101125fc943de3103b7d3bbc81 Mon Sep 17 00:00:00 2001 From: Fady Mondy Date: Mon, 25 Nov 2024 13:14:28 +0200 Subject: [PATCH] inject Filament Notifications to the driver abstract --- src/Services/Drivers/DatabaseDriver.php | 1 + src/Services/Drivers/Driver.php | 7 +++++-- src/Services/Drivers/EmailDriver.php | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Services/Drivers/DatabaseDriver.php b/src/Services/Drivers/DatabaseDriver.php index 64b09bd..794f342 100644 --- a/src/Services/Drivers/DatabaseDriver.php +++ b/src/Services/Drivers/DatabaseDriver.php @@ -23,6 +23,7 @@ public function sendIt( ?string $action = 'system', ?array $data = [], ?int $template_id = null, + ?Notification $notification = null ): void { if ($modelId) { dispatch(new NotifyDatabaseJob([ diff --git a/src/Services/Drivers/Driver.php b/src/Services/Drivers/Driver.php index 8c5986f..06890b4 100644 --- a/src/Services/Drivers/Driver.php +++ b/src/Services/Drivers/Driver.php @@ -2,6 +2,7 @@ namespace TomatoPHP\FilamentAlerts\Services\Drivers; +use Filament\Notifications\Notification; use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts; abstract class Driver @@ -19,7 +20,8 @@ abstract public function sendIt( ?string $type = 'info', ?string $action = 'system', ?array $data = [], - ?int $template_id = null + ?int $template_id = null, + ?Notification $notification = null ): void; public function send( @@ -28,7 +30,8 @@ public function send( int | string | null $modelId = null, array $title = [], array $body = [], - array $data = [] + array $data = [], + ?Notification $notification = null ): void { $loadTemplate = FilamentAlerts::loadTemplate( $template, diff --git a/src/Services/Drivers/EmailDriver.php b/src/Services/Drivers/EmailDriver.php index 6d8db6e..94e7eb1 100644 --- a/src/Services/Drivers/EmailDriver.php +++ b/src/Services/Drivers/EmailDriver.php @@ -23,6 +23,7 @@ public function sendIt( ?string $action = 'system', ?array $data = [], ?int $template_id = null, + ?Notification $notification = null ): void { if ($modelId) { $email = $model::find($modelId)?->email;