company->db); App::forgetInstance('translator'); /* Init a new copy of the translator */ $t = app('translator'); /* Set the locale */ App::setLocale($this->company->getLocale()); /* Set customized translations _NOW_ */ $t->replace(Ninja::transformTranslations($this->company->settings)); $mail_obj = new stdClass(); $mail_obj->amount = 0; $mail_obj->subject = $this->getSubject(); $mail_obj->data = $this->getData(); $mail_obj->markdown = 'email.admin.generic_table'; $mail_obj->tag = $this->company->company_key; $mail_obj->text_view = 'email.admin.generic_table_text'; return $mail_obj; } private function getSubject() { $timezone = $this->company->timezone(); $timezone_name = $timezone ? $timezone->name : 'UTC'; // Get the current hour in the company's timezone $now_in_company_tz = Carbon::now($timezone_name); $date = $this->translateDate($now_in_company_tz->format('Y-m-d'), $this->company->date_format(), $this->company->locale()); return ctrans( 'texts.notification_invoice_overdue_summary_subject', [ 'date' => $date ] ); } private function getData() { $invoice = Invoice::withTrashed()->find(reset($this->overdue_invoices)['id']); $overdue_invoices_collection = array_map( fn($row) => \Illuminate\Support\Arr::except($row, ['id', 'amount', 'due_date']), $this->overdue_invoices ); $data = [ 'title' => $this->getSubject(), 'content' => ctrans('texts.notification_invoice_overdue_summary'), 'url' => $invoice->invitations->first()->getAdminLink($this->use_react_url), 'button' => $this->use_react_url ? ctrans('texts.view_invoice') : ctrans('texts.login'), 'signature' => $this->company->settings->email_signature, 'logo' => $this->company->present()->logo(), 'settings' => $this->company->settings, 'whitelabel' => $this->company->account->isPaid() ? true : false, 'text_body' => ctrans('texts.notification_invoice_overdue_summary'), 'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin', 'table' => $overdue_invoices_collection, 'table_headers' => $this->table_headers, ]; return $data; } }