-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle filament email verification override. Fix long urls in email
- Loading branch information
1 parent
e0749c1
commit 8976a22
Showing
8 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Visualbuilder\EmailTemplates\Listeners; | ||
|
||
use Exception; | ||
use Filament\Facades\Filament; | ||
use Visualbuilder\EmailTemplates\Notifications\UserVerifyEmailNotification; | ||
use Illuminate\Auth\Events\Registered; | ||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification as BaseListener; | ||
use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
|
||
class SendEmailVerificationListener extends BaseListener | ||
{ | ||
public function handle(Registered $event): void | ||
{ | ||
if (! $event->user instanceof MustVerifyEmail) { | ||
return; | ||
} | ||
|
||
if ($event->user->hasVerifiedEmail()) { | ||
return; | ||
} | ||
|
||
if (! method_exists($event->user, 'notify')) { | ||
$userClass = $event->user::class; | ||
|
||
throw new Exception("Model [{$userClass}] does not have a [notify()] method."); | ||
} | ||
|
||
$notification = new UserVerifyEmailNotification(Filament::getVerifyEmailUrl($event->user)); | ||
|
||
$event->user->notify($notification); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Visualbuilder\EmailTemplates\Notifications; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
use Visualbuilder\EmailTemplates\Mail\UserVerifiedEmail; | ||
use Visualbuilder\EmailTemplates\Mail\UserVerifyEmail; | ||
|
||
class UserVerifyEmailNotification extends Notification | ||
{ | ||
use Queueable; | ||
|
||
public string $url; | ||
|
||
|
||
/** | ||
* Create a new notification instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct($url) | ||
{ | ||
$this->url = $url; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['mail']; | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return \Illuminate\Notifications\Messages\MailMessage | ||
*/ | ||
public function toMail($notifiable) | ||
{ | ||
if(config('filament-email-templates.send_emails.verification')) { | ||
return app(UserVerifyEmail::class, ['user' => $notifiable,'url'=>$this->url]); | ||
} | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function toArray($notifiable) | ||
{ | ||
return [ | ||
|
||
]; | ||
} | ||
} |