File tree Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ public function run(): void
3030 ShippingZoneSeeder::class,
3131 ShippingMethodSeeder::class,
3232 ShippingRateSeeder::class,
33+ // BundleSeeder::class, // Temporarily disabled due to total_price constraint issue
3334 SeoDataSeeder::class,
3435 ]);
3536 }
Original file line number Diff line number Diff line change @@ -38,7 +38,10 @@ public function run(): void
3838 ];
3939
4040 foreach ($ methods as $ method ) {
41- ShippingMethod::create ($ method );
41+ ShippingMethod::firstOrCreate (
42+ ['code ' => $ method ['code ' ]],
43+ $ method
44+ );
4245 }
4346
4447 $ this ->command ->info ('Created ' . count ($ methods ) . ' shipping methods ' );
Original file line number Diff line number Diff line change @@ -38,15 +38,19 @@ public function run(): void
3838 continue ;
3939 }
4040
41- ShippingRate::create ([
42- 'shipping_zone_id ' => $ zone ->id ,
43- 'shipping_method_id ' => $ method ->id ,
44- 'min_weight ' => $ tier ['min ' ],
45- 'max_weight ' => $ tier ['max ' ],
46- 'price ' => $ tier ['price ' ] * 100 , // Convert to cents
47- 'currency ' => 'AUD ' ,
48- 'is_active ' => true ,
49- ]);
41+ ShippingRate::firstOrCreate (
42+ [
43+ 'shipping_zone_id ' => $ zone ->id ,
44+ 'shipping_method_id ' => $ method ->id ,
45+ 'min_weight ' => $ tier ['min ' ],
46+ 'max_weight ' => $ tier ['max ' ],
47+ ],
48+ [
49+ 'price ' => $ tier ['price ' ] * 100 , // Convert to cents
50+ 'currency ' => 'AUD ' ,
51+ 'is_active ' => true ,
52+ ]
53+ );
5054
5155 $ createdRates ++;
5256 }
Original file line number Diff line number Diff line change @@ -59,7 +59,10 @@ public function run(): void
5959 ];
6060
6161 foreach ($ zones as $ zone ) {
62- ShippingZone::create ($ zone );
62+ ShippingZone::firstOrCreate (
63+ ['postcode_pattern ' => $ zone ['postcode_pattern ' ]],
64+ $ zone
65+ );
6366 }
6467
6568 $ this ->command ->info ('Created ' . count ($ zones ) . ' Australian shipping zones ' );
You can’t perform that action at this time.
0 commit comments