Skip to content

Commit

Permalink
Update notification to use config assigned mailable to allow custom m…
Browse files Browse the repository at this point in the history
…ail class

Aravind & Akshay...
Note also the config still includes references to Events that are no longer existing -> do we need to put them back or not used anymore?
  • Loading branch information
cannycookie committed Feb 26, 2024
1 parent 022df14 commit bc35ee4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions config/filament-user-consent.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Visualbuilder\FilamentUserConsent\Events\ConsentsUpdatedComplete;
use Visualbuilder\FilamentUserConsent\Events\ConsentUpdated;
//use Visualbuilder\FilamentUserConsent\Events\ConsentsUpdatedComplete;
//use Visualbuilder\FilamentUserConsent\Events\ConsentUpdated;
use Visualbuilder\FilamentUserConsent\Listeners\NotifyConsentsUpdated;

return [
Expand Down Expand Up @@ -46,4 +46,7 @@
'notify' => ['mail'],

'email-template' => 'vendor.user-consent.layouts.email',

//The mailable class to use for sending consent notification
'mailable' => \Visualbuilder\FilamentUserConsent\Mail\ConsentsUpdatedMail::class
];
10 changes: 8 additions & 2 deletions src/Notifications/ConsentsUpdatedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ public function via($notifiable)
*
* @param mixed $notifiable
*/
public function toMail($notifiable): ConsentsUpdatedMail
public function toMail($notifiable)
{
return new ConsentsUpdatedMail($notifiable);
// Retrieve the class name from the package configuration
$mailableClass = config('filament-user-consent.mailable');

// Dynamically instantiate the Mailable class with the $notifiable data
$mailable = new $mailableClass($notifiable);

return $mailable;
}

/**
Expand Down

0 comments on commit bc35ee4

Please sign in to comment.