getRoleExpiryInfo(); $pendingRole = $roleExpiryInfo['pending_role']; $pendingStart = $roleExpiryInfo['pending_start']; $this->days = $days; $this->username = (string) $user->username; $this->account = (string) ($user->role->name ?? 'User'); $this->hasPendingRole = (bool) $roleExpiryInfo['has_pending_role'] && $pendingRole !== null && $pendingStart !== null; $this->pendingRoleName = $this->hasPendingRole ? (string) $pendingRole->name : null; $this->pendingRoleStartDate = $this->hasPendingRole ? $pendingStart->toFormattedDateString() : null; $this->siteEmail = (string) config('mail.from.address'); $this->site = (string) config('app.name'); $this->preheader = $this->hasPendingRole ? "Your {$this->account} role expires in {$this->days} day(s), then {$this->pendingRoleName} is scheduled." : "Your {$this->account} role expires in {$this->days} day(s)."; } public function build(): static { return $this->from($this->siteEmail) ->brandedSubject('Your account is about to expire') ->markdown('emails.markdown.accountWillExpire', [ 'username' => $this->username, 'account' => $this->account, 'days' => $this->days, 'hasPendingRole' => $this->hasPendingRole, 'pendingRoleName' => $this->pendingRoleName, 'pendingRoleStartDate' => $this->pendingRoleStartDate, 'site' => $this->site, 'preheader' => $this->preheader, ]); } }