45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class NewLoginDetected extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public string $ip;
|
|
public string $userAgent;
|
|
public string $loginAt;
|
|
|
|
public function __construct(string $ip, string $userAgent, string $loginAt)
|
|
{
|
|
$this->ip = $ip;
|
|
$this->userAgent = $userAgent;
|
|
$this->loginAt = $loginAt;
|
|
}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
return (new MailMessage)
|
|
->subject('New Login Detected on Your Account')
|
|
->view('emails.new-login', [
|
|
'user' => $notifiable,
|
|
'ip' => $this->ip,
|
|
'userAgent' => $this->userAgent,
|
|
'loginAt' => $this->loginAt,
|
|
'appName' => config('app.name'),
|
|
'supportEmail' => config('mail.from.address'),
|
|
'manageLink' => url('/settings/security'),
|
|
]);
|
|
}
|
|
}
|