91 lines
3.0 KiB
PHP
91 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
class InactiveProfileWarningFinalMail extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public $profile;
|
|
public $profileType;
|
|
public $timeRemaining;
|
|
public $daysRemaining;
|
|
public $accounts;
|
|
public $totalBalance;
|
|
public $daysSinceLogin;
|
|
public $locale;
|
|
public $loginUrl;
|
|
|
|
public function __construct($profile, $profileType, $timeRemaining, $daysRemaining, $accounts, $totalBalance, $daysSinceLogin)
|
|
{
|
|
$this->profile = $profile;
|
|
$this->profileType = $profileType;
|
|
$this->timeRemaining = $timeRemaining;
|
|
$this->daysRemaining = $daysRemaining;
|
|
$this->accounts = $accounts;
|
|
$this->totalBalance = $totalBalance;
|
|
$this->daysSinceLogin = $daysSinceLogin;
|
|
|
|
// Set locale from profile preference
|
|
$this->locale = $profile->lang_preference ?? config('app.fallback_locale', 'en');
|
|
|
|
// Generate direct login URL
|
|
if ($profileType === 'User') {
|
|
$this->loginUrl = route('user.direct-login', [
|
|
'userId' => $profile->id,
|
|
'name' => $profile->name
|
|
]);
|
|
} elseif ($profileType === 'Organization') {
|
|
$this->loginUrl = route('organization.direct-login', [
|
|
'organizationId' => $profile->id
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: trans('Final warning: Your profile will be deleted very soon', [], $this->locale),
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
view: 'emails.inactive-profiles.warning-final',
|
|
);
|
|
}
|
|
|
|
public function build()
|
|
{
|
|
// Set application locale for this email
|
|
app()->setLocale($this->locale);
|
|
|
|
return $this
|
|
->from(
|
|
timebank_config('mail.system_admin.email'),
|
|
timebank_config('mail.system_admin.name')
|
|
)
|
|
->subject(trans('Final warning: Your profile will be deleted very soon', [], $this->locale))
|
|
->view('emails.inactive-profiles.warning-final')
|
|
->with([
|
|
'profile' => $this->profile,
|
|
'profileType' => $this->profileType,
|
|
'timeRemaining' => $this->timeRemaining,
|
|
'daysRemaining' => $this->daysRemaining,
|
|
'accounts' => $this->accounts,
|
|
'totalBalance' => $this->totalBalance,
|
|
'daysSinceLogin' => $this->daysSinceLogin,
|
|
'loginUrl' => $this->loginUrl,
|
|
'totalInactiveDays' => timebank_config('profile_inactive.days_not_logged_in') + timebank_config('delete_profile.days_after_inactive.run_delete'),
|
|
]);
|
|
}
|
|
}
|