Created
April 24, 2025 14:50
-
-
Save stevebauman/897926385d68d9b4cc85bbad9b0d52dc to your computer and use it in GitHub Desktop.
Notifiable Guest User | Laravel
This file contains hidden or 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
<?php | |
namespace App\Support; | |
use Illuminate\Notifications\RoutesNotifications; | |
readonly class Guest | |
{ | |
use RoutesNotifications; | |
public function __construct( | |
public ?string $name = null, | |
public ?string $email = null, | |
public ?string $phoneNumber = null, | |
) {} | |
public static function billing(): static | |
{ | |
return new static( | |
name: 'Billing', | |
email: '[email protected]', | |
); | |
} | |
public static function support(): static | |
{ | |
return new static( | |
name: 'Support', | |
email: '[email protected]', | |
phoneNumber: '+155512345678' | |
); | |
} | |
public function getKey(): string | |
{ | |
return $this->email ?? $this->phoneNumber; | |
} | |
public function routeNotificationForMail(): ?string | |
{ | |
return $this->email; | |
} | |
public function routeNotificationForTelephony(): ?string | |
{ | |
return $this->phoneNumber; | |
} | |
public function routeNotificationForDatabase(): void | |
{ | |
// Do nothing. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Neat.