diff --git a/app/Http/Controllers/SelfUpdateController.php b/app/Http/Controllers/SelfUpdateController.php index f304482fac6b..75d2442fcdae 100644 --- a/app/Http/Controllers/SelfUpdateController.php +++ b/app/Http/Controllers/SelfUpdateController.php @@ -11,13 +11,14 @@ namespace App\Http\Controllers; -use App\Exceptions\FilePermissionsFailure; use App\Utils\Ninja; +use App\Models\Company; use App\Utils\Traits\AppSetup; -use App\Utils\Traits\ClientGroupSettingsSaver; -use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Storage; +use App\Exceptions\FilePermissionsFailure; +use Illuminate\Foundation\Bus\DispatchesJobs; +use App\Utils\Traits\ClientGroupSettingsSaver; class SelfUpdateController extends BaseController { @@ -109,11 +110,33 @@ class SelfUpdateController extends BaseController $this->buildCache(true); + $this->runModelChecks(); + nlog('Called Artisan commands'); return response()->json(['message' => 'Update completed'], 200); } + private function runModelChecks() + { + Company::query() + ->cursor() + ->each(function ($company){ + + $settings = $company->settings; + + if(property_exists($settings->pdf_variables, 'purchase_order_details')) + return; + + $pdf_variables = $settings->pdf_variables; + $pdf_variables->purchase_order_details = []; + $settings->pdf_variables = $pdf_variables; + $company->settings = $settings; + $company->save(); + + }); + } + private function clearCacheDir() { $directoryIterator = new \RecursiveDirectoryIterator(base_path('bootstrap/cache'), \RecursiveDirectoryIterator::SKIP_DOTS); diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index a97444ba89ee..edb8c2e2aa5a 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -195,15 +195,15 @@ class PdfSlot extends Component } elseif($this->entity_type == 'quote'){ - foreach($this->settings->pdf_variables->quote_details as $variable) + foreach($this->settings->pdf_variables->quote_details ?? [] as $variable) $entity_details .= "
{$variable}_label
{$variable}
{$variable}_label
{$variable}
{$variable}_label
{$variable}