diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index dd9a0c7ff7..1b35812598 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -237,7 +237,7 @@ class BillingPortalPurchase extends Component $client_repo = new ClientRepository(new ClientContactRepository()); $data = [ - 'name' => 'Client Name', + 'name' => '', 'contacts' => [ ['email' => $this->email], ], diff --git a/app/Mail/Admin/AccountCreatedObject.php b/app/Mail/Admin/AccountCreatedObject.php index d6f0ac47f7..27fd61d089 100644 --- a/app/Mail/Admin/AccountCreatedObject.php +++ b/app/Mail/Admin/AccountCreatedObject.php @@ -11,6 +11,9 @@ namespace App\Mail\Admin; +use App\Utils\Ninja; +use Illuminate\Support\Facades\App; + class AccountCreatedObject { @@ -30,6 +33,14 @@ class AccountCreatedObject public function build() { + 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)); + $data = [ 'title' => ctrans('texts.new_signup'), 'message' => ctrans('texts.new_signup_text', ['user' => $this->user->present()->name(), 'email' => $this->user->email, 'ip' => $this->user->ip]), diff --git a/app/Mail/Admin/AutoBillingFailureObject.php b/app/Mail/Admin/AutoBillingFailureObject.php index 9227ee78f4..a642eee526 100644 --- a/app/Mail/Admin/AutoBillingFailureObject.php +++ b/app/Mail/Admin/AutoBillingFailureObject.php @@ -13,8 +13,10 @@ namespace App\Mail\Admin; use App\Models\Invoice; use App\Utils\HtmlEngine; +use App\Utils\Ninja; use App\Utils\Number; use App\Utils\Traits\MakesHash; +use Illuminate\Support\Facades\App; use stdClass; class AutoBillingFailureObject @@ -55,6 +57,15 @@ class AutoBillingFailureObject public function build() { + + 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)); + $this->$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->get(); $mail_obj = new stdClass; diff --git a/app/Mail/Admin/ClientPaymentFailureObject.php b/app/Mail/Admin/ClientPaymentFailureObject.php index 599e2b6089..3489274ba1 100644 --- a/app/Mail/Admin/ClientPaymentFailureObject.php +++ b/app/Mail/Admin/ClientPaymentFailureObject.php @@ -13,8 +13,10 @@ namespace App\Mail\Admin; use App\Models\Invoice; use App\Utils\HtmlEngine; +use App\Utils\Ninja; use App\Utils\Number; use App\Utils\Traits\MakesHash; +use Illuminate\Support\Facades\App; use stdClass; class ClientPaymentFailureObject @@ -56,6 +58,14 @@ class ClientPaymentFailureObject public function build() { + 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)); + $this->invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->get(); $mail_obj = new stdClass; diff --git a/app/Mail/Admin/EntityCreatedObject.php b/app/Mail/Admin/EntityCreatedObject.php index 6a4120fb31..9dbd4a54a4 100644 --- a/app/Mail/Admin/EntityCreatedObject.php +++ b/app/Mail/Admin/EntityCreatedObject.php @@ -11,8 +11,10 @@ namespace App\Mail\Admin; +use App\Utils\Ninja; use App\Utils\Number; use stdClass; +use Illuminate\Support\Facades\App; class EntityCreatedObject { @@ -39,6 +41,13 @@ class EntityCreatedObject public function build() { + 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)); $this->contact = $this->entity->invitations()->first()->contact; $this->company = $this->entity->company; diff --git a/app/Mail/Admin/EntityFailedSendObject.php b/app/Mail/Admin/EntityFailedSendObject.php index aeec205726..3330b73a1f 100644 --- a/app/Mail/Admin/EntityFailedSendObject.php +++ b/app/Mail/Admin/EntityFailedSendObject.php @@ -12,8 +12,10 @@ namespace App\Mail\Admin; use App\Utils\HtmlEngine; +use App\Utils\Ninja; use App\Utils\Number; use stdClass; + use Illuminate\Support\Facades\App; class EntityFailedSendObject { @@ -50,6 +52,15 @@ class EntityFailedSendObject public function build() { + + 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)); + $this->setTemplate(); $mail_obj = new stdClass; diff --git a/app/Mail/Admin/EntityPaidObject.php b/app/Mail/Admin/EntityPaidObject.php index ef6958efe2..fb031e5b5a 100644 --- a/app/Mail/Admin/EntityPaidObject.php +++ b/app/Mail/Admin/EntityPaidObject.php @@ -12,7 +12,9 @@ namespace App\Mail\Admin; use App\Mail\Engine\PaymentEmailEngine; +use App\Utils\Ninja; use App\Utils\Number; +use Illuminate\Support\Facades\App; use stdClass; class EntityPaidObject @@ -35,6 +37,15 @@ class EntityPaidObject public function build() { + + 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 = $this->getAmount(); $mail_obj->subject = $this->getSubject(); diff --git a/app/Mail/Admin/EntitySentObject.php b/app/Mail/Admin/EntitySentObject.php index 6a7ee56935..3b9003e07e 100644 --- a/app/Mail/Admin/EntitySentObject.php +++ b/app/Mail/Admin/EntitySentObject.php @@ -11,8 +11,10 @@ namespace App\Mail\Admin; +use App\Utils\Ninja; use App\Utils\Number; use stdClass; +use Illuminate\Support\Facades\App; class EntitySentObject { @@ -46,6 +48,15 @@ class EntitySentObject public function build() { + + 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)); + $this->setTemplate(); $mail_obj = new stdClass; diff --git a/app/Mail/Admin/EntityViewedObject.php b/app/Mail/Admin/EntityViewedObject.php index e5402b2da4..90a7588eee 100644 --- a/app/Mail/Admin/EntityViewedObject.php +++ b/app/Mail/Admin/EntityViewedObject.php @@ -11,8 +11,10 @@ namespace App\Mail\Admin; +use App\Utils\Ninja; use App\Utils\Number; use stdClass; +use Illuminate\Support\Facades\App; class EntityViewedObject { @@ -39,6 +41,15 @@ class EntityViewedObject public function build() { + + 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 = $this->getAmount(); $mail_obj->subject = $this->getSubject(); diff --git a/app/Mail/Admin/PaymentFailureObject.php b/app/Mail/Admin/PaymentFailureObject.php index 355e35f73b..45068871bc 100644 --- a/app/Mail/Admin/PaymentFailureObject.php +++ b/app/Mail/Admin/PaymentFailureObject.php @@ -12,9 +12,11 @@ namespace App\Mail\Admin; use App\Models\Invoice; +use App\Utils\Ninja; use App\Utils\Number; use App\Utils\Traits\MakesHash; use stdClass; +use Illuminate\Support\Facades\App; class PaymentFailureObject { @@ -55,6 +57,14 @@ class PaymentFailureObject public function build() { + 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)); + // $this->invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->get(); $mail_obj = new stdClass; diff --git a/app/Mail/Admin/ResetPasswordObject.php b/app/Mail/Admin/ResetPasswordObject.php index 7a41ffb797..85f0a117a1 100644 --- a/app/Mail/Admin/ResetPasswordObject.php +++ b/app/Mail/Admin/ResetPasswordObject.php @@ -11,6 +11,9 @@ namespace App\Mail\Admin; +use App\Utils\Ninja; +use Illuminate\Support\Facades\App; + class ResetPasswordObject { @@ -32,6 +35,14 @@ class ResetPasswordObject public function build() { + 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)); + $data = [ 'title' => ctrans('texts.your_password_reset_link'), 'message' => ctrans('texts.reset_password'), diff --git a/app/Mail/Admin/VerifyUserObject.php b/app/Mail/Admin/VerifyUserObject.php index 26b39ce1a8..2146fabef0 100644 --- a/app/Mail/Admin/VerifyUserObject.php +++ b/app/Mail/Admin/VerifyUserObject.php @@ -11,7 +11,9 @@ namespace App\Mail\Admin; +use App\Utils\Ninja; use App\Utils\Traits\MakesHash; +use Illuminate\Support\Facades\App; class VerifyUserObject { @@ -33,6 +35,15 @@ class VerifyUserObject public function build() { + + 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)); + $this->user->confirmation_code = $this->createDbHash($this->company->db); $this->user->save(); diff --git a/app/Mail/ClientContact/ClientContactResetPasswordObject.php b/app/Mail/ClientContact/ClientContactResetPasswordObject.php index 1065b1cb6e..77fdeba300 100644 --- a/app/Mail/ClientContact/ClientContactResetPasswordObject.php +++ b/app/Mail/ClientContact/ClientContactResetPasswordObject.php @@ -11,6 +11,9 @@ namespace App\Mail\ClientContact; +use App\Utils\Ninja; +use Illuminate\Support\Facades\App; + class ClientContactResetPasswordObject { @@ -32,6 +35,12 @@ class ClientContactResetPasswordObject public function build() { + App::forgetInstance('translator'); + $t = app('translator'); + App::setLocale($this->client_contact->preferredLocale()); + $t->replace(Ninja::transformTranslations($this->client_contact->client->getMergedSettings())); + + $data = [ 'title' => ctrans('texts.your_password_reset_link'), 'content' => ctrans('texts.reset_password'), diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index 1f878bb543..d008f38f0b 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -17,6 +17,7 @@ use App\Utils\Helpers; use App\Utils\Ninja; use App\Utils\Number; use App\Utils\Traits\MakesDates; +use Illuminate\Support\Facades\App; class PaymentEmailEngine extends BaseEmailEngine { @@ -49,6 +50,11 @@ class PaymentEmailEngine extends BaseEmailEngine public function build() { + App::forgetInstance('translator'); + $t = app('translator'); + App::setLocale($this->contact->preferredLocale()); + $t->replace(Ninja::transformTranslations($this->client->getMergedSettings())); + if (is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) { $body_template = $this->template_data['body']; } elseif (strlen($this->client->getSetting('email_template_payment')) > 0) { diff --git a/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php b/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php index e6a4ec79de..a21b1dd55e 100644 --- a/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php +++ b/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php @@ -11,6 +11,9 @@ namespace App\Mail\RecurringInvoice; +use App\Utils\Ninja; +use Illuminate\Support\Facades\App; + class ClientContactRequestCancellationObject { @@ -33,6 +36,10 @@ class ClientContactRequestCancellationObject public function build() { + App::forgetInstance('translator'); + $t = app('translator'); + $t->replace(Ninja::transformTranslations($this->company->settings)); + $data = [ 'title' => ctrans('texts.recurring_cancellation_request', ['contact' => $this->client_contact->present()->name()]), 'content' => ctrans('texts.recurring_cancellation_request_body', ['contact' => $this->client_contact->present()->name(), 'client' => $this->client_contact->client->present()->name(), 'invoice' => $this->recurring_invoice->number]), diff --git a/app/Models/Company.php b/app/Models/Company.php index bb139f0426..6f69002cdf 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -11,6 +11,7 @@ namespace App\Models; +use App\Models\Language; use App\Models\Presenters\CompanyPresenter; use App\Models\User; use App\Services\Notification\NotificationService; diff --git a/app/Models/User.php b/app/Models/User.php index bcbb0214ec..8c6ad83f8d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -31,6 +31,7 @@ use Illuminate\Support\Carbon; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Laracasts\Presenter\PresentableTrait; +use Illuminate\Support\Facades\Cache; class User extends Authenticatable implements MustVerifyEmail {