From edf5077ff69def15d3fbee20e87716af8d6bc1bd Mon Sep 17 00:00:00 2001 From: Alec Ritson Date: Thu, 2 Jan 2025 10:07:38 +0000 Subject: [PATCH] Associate countries to tax zone --- packages/core/src/Console/InstallLunar.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/core/src/Console/InstallLunar.php b/packages/core/src/Console/InstallLunar.php index ed9f889f74..15b4d705b8 100644 --- a/packages/core/src/Console/InstallLunar.php +++ b/packages/core/src/Console/InstallLunar.php @@ -19,7 +19,7 @@ use Lunar\Models\Product; use Lunar\Models\ProductType; use Lunar\Models\TaxClass; - +use Lunar\Models\TaxZone; use function Laravel\Prompts\confirm; class InstallLunar extends Command @@ -136,6 +136,23 @@ public function handle(): void ]); } + if (! TaxZone::count()) { + $this->components->info('Adding a default tax zone.'); + + $taxZone = TaxZone::create([ + 'name' => 'Default Tax Zone', + 'zone_type' => 'country', + 'price_display' => 'tax_exclusive', + 'default' => true, + 'active' => true, + ]); + $taxZone->countries()->createMany( + Country::get()->map(fn ($country) => [ + 'country_id' => $country->id, + ]) + ); + } + if (! Attribute::count()) { $this->components->info('Setting up initial attributes');