From c4a0a8ee1419bf21363b5348088302e20cc783a0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Nov 2023 12:16:15 +1100 Subject: [PATCH] Ensure multidb set in PdfConfiguration --- app/Jobs/Inventory/AdjustProductInventory.php | 4 +++- app/Services/Pdf/PdfConfiguration.php | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index e5f3bba28217..1f1ab6b7db83 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -137,8 +137,10 @@ class AdjustProductInventory implements ShouldQueue $nmo->company = $this->company; $nmo->settings = $this->company->settings; - /** @var \App\Models\CompanyUser $cu */ + $this->company->company_users->each(function ($cu) use ($product, $nmo, $notification_level) { + + /** @var \App\Models\CompanyUser $cu */ if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user', 'inventory_threshold_all', 'inventory_threshold_user']) && (! in_array($product->id, $this->notified_products))) { $nmo->mailable = new NinjaMailer((new InventoryNotificationObject($product, $notification_level, $cu->portalType()))->build()); $nmo->to_user = $cu->user; diff --git a/app/Services/Pdf/PdfConfiguration.php b/app/Services/Pdf/PdfConfiguration.php index 9ab8751bb870..a1982fc13193 100644 --- a/app/Services/Pdf/PdfConfiguration.php +++ b/app/Services/Pdf/PdfConfiguration.php @@ -12,6 +12,7 @@ namespace App\Services\Pdf; use App\DataMapper\CompanySettings; +use App\Libraries\MultiDB; use App\Models\Client; use App\Models\ClientContact; use App\Models\Country; @@ -94,6 +95,8 @@ class PdfConfiguration */ public function init(): self { + MultiDB::setDb($this->service->company->db); + $this->setEntityType() ->setDateFormat() ->setPdfVariables() @@ -271,8 +274,8 @@ class PdfConfiguration */ private function setDesign(): self { - $design_id = $this->entity->design_id ? : $this->decodePrimaryKey($this->settings_object->getSetting($this->entity_design_id)); - + $design_id = $this->entity->design_id ?: $this->decodePrimaryKey($this->settings_object->getSetting($this->entity_design_id)); + $this->design = Design::withTrashed()->find($design_id ?? 2); return $this;