Ensure multidb set in PdfConfiguration

This commit is contained in:
David Bomba 2023-11-13 12:16:15 +11:00
parent 7964069e5b
commit c4a0a8ee14
2 changed files with 8 additions and 3 deletions

View File

@ -137,8 +137,10 @@ class AdjustProductInventory implements ShouldQueue
$nmo->company = $this->company; $nmo->company = $this->company;
$nmo->settings = $this->company->settings; $nmo->settings = $this->company->settings;
/** @var \App\Models\CompanyUser $cu */
$this->company->company_users->each(function ($cu) use ($product, $nmo, $notification_level) { $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))) { 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->mailable = new NinjaMailer((new InventoryNotificationObject($product, $notification_level, $cu->portalType()))->build());
$nmo->to_user = $cu->user; $nmo->to_user = $cu->user;

View File

@ -12,6 +12,7 @@
namespace App\Services\Pdf; namespace App\Services\Pdf;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\Libraries\MultiDB;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact; use App\Models\ClientContact;
use App\Models\Country; use App\Models\Country;
@ -94,6 +95,8 @@ class PdfConfiguration
*/ */
public function init(): self public function init(): self
{ {
MultiDB::setDb($this->service->company->db);
$this->setEntityType() $this->setEntityType()
->setDateFormat() ->setDateFormat()
->setPdfVariables() ->setPdfVariables()
@ -271,8 +274,8 @@ class PdfConfiguration
*/ */
private function setDesign(): self 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); $this->design = Design::withTrashed()->find($design_id ?? 2);
return $this; return $this;