2021-05-12 08:18:32 +02:00
|
|
|
<?php
|
2021-06-09 16:57:16 +02:00
|
|
|
|
2021-05-12 08:18:32 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-05-12 08:18:32 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-05-12 08:18:32 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Mail\User;
|
|
|
|
|
2024-02-03 12:26:43 +01:00
|
|
|
use App\Models\User;
|
|
|
|
use App\Models\Company;
|
2021-05-12 08:18:32 +02:00
|
|
|
use Illuminate\Mail\Mailable;
|
2021-12-30 21:41:50 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2021-05-12 08:18:32 +02:00
|
|
|
|
|
|
|
class UserLoggedIn extends Mailable
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create a new message instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2024-02-03 12:26:43 +01:00
|
|
|
public function __construct(public User $user, public Company $company, public string $ip)
|
2021-05-12 08:18:32 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the message.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function build()
|
|
|
|
{
|
2021-12-30 21:41:50 +01:00
|
|
|
App::setLocale($this->company->getLocale());
|
|
|
|
|
2024-02-03 12:26:43 +01:00
|
|
|
$text = ctrans('texts.new_login_description', ['email' => $this->user->email, 'ip' => $this->ip, 'time' => now()]);
|
|
|
|
|
2021-05-12 08:18:32 +02:00
|
|
|
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
2021-06-09 16:57:16 +02:00
|
|
|
->subject(ctrans('texts.new_login_detected'))
|
2022-06-21 11:57:17 +02:00
|
|
|
->text('email.admin.generic_text', [
|
2022-03-04 04:01:09 +01:00
|
|
|
'title' => ctrans('texts.new_login_detected'),
|
2024-02-03 12:26:43 +01:00
|
|
|
'body' => $text,
|
2022-03-04 04:01:09 +01:00
|
|
|
])
|
2021-06-09 16:57:16 +02:00
|
|
|
->view('email.admin.notification')
|
|
|
|
->with([
|
|
|
|
'settings' => $this->company->settings,
|
|
|
|
'logo' => $this->company->present()->logo(),
|
|
|
|
'title' => ctrans('texts.new_login_detected'),
|
|
|
|
'body' => ctrans('texts.new_login_description', ['email' => $this->user->email, 'ip' => $this->ip, 'time' => now()]),
|
|
|
|
'whitelabel' => $this->company->account->isPaid(),
|
|
|
|
]);
|
2021-05-12 08:18:32 +02:00
|
|
|
}
|
|
|
|
}
|