2024-10-19 23:11:04 -05:00
< ? php
2025-01-28 17:33:54 -06:00
declare ( strict_types = 1 );
2024-10-19 23:11:04 -05:00
namespace App\Notifications ;
2024-10-22 21:24:04 -05:00
use App\Models\ConnectedAccount ;
2025-01-28 17:14:49 -06:00
use Illuminate\Bus\Queueable ;
2024-10-19 23:11:04 -05:00
use Illuminate\Contracts\Queue\ShouldQueue ;
use Illuminate\Notifications\Messages\MailMessage ;
2025-01-28 17:14:49 -06:00
use Illuminate\Notifications\Notification ;
2024-10-19 23:11:04 -05:00
class VerifyConnectedAccountNotification extends Notification implements ShouldQueue
{
use Queueable ;
/**
* Create a new notification instance.
*/
public function __construct (
2024-10-22 21:24:04 -05:00
public string $connected_account_id
2025-01-28 17:14:49 -06:00
) {}
2024-10-19 23:11:04 -05:00
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via ( object $notifiable ) : array
{
return [ 'mail' ];
}
/**
* Get the mail representation of the notification.
*/
public function toMail ( object $notifiable ) : MailMessage
{
2024-10-22 21:24:04 -05:00
$connected_account = ConnectedAccount :: find ( $this -> connected_account_id );
$provider = config ( " services. $connected_account->provider .name " );
2024-10-19 23:11:04 -05:00
2024-10-22 21:24:04 -05:00
$url = url () -> signedRoute ( 'oauth.verify_connected_account' , [ 'connected_account' => $this -> connected_account_id ], now () -> days ( $days = 7 ));
2024-10-22 20:29:54 -05:00
2024-10-19 23:11:04 -05:00
return ( new MailMessage )
2025-01-28 17:14:49 -06:00
-> greeting ( 'Welcome back!' )
-> subject ( " Connect your $provider account with Investbrain " )
-> line ( " You recently attempted to log into an existing Investbrain account using $provider . To safeguard your Investbrain account, please confirm this was you by pressing the 'Connect $provider ' button below: " )
-> action ( " Connect $provider " , $url )
-> line ( 'If you do not recognize this activity, we recommend [changing your password](' . route ( 'profile.show' ) . " ) as soon as possible. Otherwise, you can disregard this message. This link will expire in { $days } days. " );
2024-10-19 23:11:04 -05:00
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray ( object $notifiable ) : array
{
return [
//
];
}
}