diff --git a/app/Models/Product.php b/app/Models/Product.php index f9133b7..7414a24 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -316,7 +316,7 @@ class Product extends Model implements IDs static $default = NULL; if (! $go) { if (is_null($default)) - $default = Group::findOrFail(0); // All public users + $default = Group::whereNull('parent_id')->firstOrFail(); // All public users $go = $default; } diff --git a/database/factories/AccountFactory.php b/database/factories/AccountFactory.php index de90f7c..f71544c 100644 --- a/database/factories/AccountFactory.php +++ b/database/factories/AccountFactory.php @@ -24,8 +24,6 @@ class AccountFactory extends Factory { // Create Dependencies - should be loaded by seeding. $co = Country::findOrFail(61); - $lo = Language::findOrFail(1); - $cyo = Currency::findOrFail(6); return [ 'id' => $this->faker->numberBetween(2048,65535), @@ -33,10 +31,8 @@ class AccountFactory extends Factory // 'date_last', //* 'site_id', // Needs to be passed in // 'date_expire', - 'language_id' => $lo->id, 'country_id' => $co->id, // 'rtm_id', - 'currency_id' => $cyo->id, 'active' => TRUE, // 'company', // 'address1', diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index 164a1a0..78387c0 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -36,11 +36,12 @@ class ProductFactory extends Factory // 'group_avail' // 'avail_category' // 'price_type' - 'price_group'=>serialize([ - 1=>[ - 0=>[ - 'price_setup'=>50, - 'price_base'=>100, + 'pricing'=>json_encode([ + [ + 'show'=>true, + [ + 'setup'=>50, + 'base'=>100, ] ] ]), diff --git a/database/factories/ServiceFactory.php b/database/factories/ServiceFactory.php index 28903d9..c853f1c 100644 --- a/database/factories/ServiceFactory.php +++ b/database/factories/ServiceFactory.php @@ -65,7 +65,7 @@ class ServiceFactory extends Factory // 'orderedby_id', // 'order_status', // 'order_info', - 'model' => 'App\Models\Service\Adsl', + 'model' => 'App\Models\Service\Broadband', ]; } } diff --git a/database/migrations/2021_12_20_225017_optimize_product.php b/database/migrations/2021_12_20_225017_optimize_product.php index 3b837a0..6a49afb 100644 --- a/database/migrations/2021_12_20_225017_optimize_product.php +++ b/database/migrations/2021_12_20_225017_optimize_product.php @@ -13,6 +13,8 @@ class OptimizeProduct extends Migration */ public function up() { + $site = \App\Models\Site::where('site_id',1)->firstOrNew(); + Schema::table('ab_product', function (Blueprint $table) { $table->dropForeign(['site_id']); $table->dropIndex(['id','site_id']); @@ -490,6 +492,10 @@ class OptimizeProduct extends Migration } } + // No need to update tables, if we dont have a site setup yet. + if (! $site->exists) + return; + // SSL $so = \App\Models\Supplier::where('name','Graytech Hosting Pty Ltd')->firstOrNew(); $so->name = 'Graytech Hosting Pty Ltd'; @@ -500,7 +506,7 @@ class OptimizeProduct extends Migration ->where('site_id','1') ->where('supplier_id',$so->id) ->firstOrNew(); - $sdo->site_id = 1; + $sdo->site_id = $site->site_id; $so->detail()->save($sdo); $o = new \App\Models\Supplier\SSL; @@ -538,7 +544,7 @@ class OptimizeProduct extends Migration ->where('site_id','1') ->where('supplier_id',$so->id) ->firstOrNew(); - $sdo->site_id = 1; + $sdo->site_id = $site->site_id; $so->detail()->save($sdo); $o = new \App\Models\Supplier\Host; @@ -561,7 +567,7 @@ class OptimizeProduct extends Migration ->where('site_id','1') ->where('supplier_id',$so->id) ->firstOrNew(); - $sdo->site_id = 1; + $sdo->site_id = $site->site_id; $so->detail()->save($sdo); $o = new \App\Models\Supplier\Voip; diff --git a/database/seeders/CountryTableSeeder.php b/database/seeders/CountryTableSeeder.php index bc43eed..a3c8070 100644 --- a/database/seeders/CountryTableSeeder.php +++ b/database/seeders/CountryTableSeeder.php @@ -22,7 +22,7 @@ class CountryTableSeeder extends Seeder $o->three_code = 'AUS'; $o->active = TRUE; - $oo = Currency::where('iso_code','AUD')->firstOrFail(); + $oo = Currency::where('iso','AUD')->firstOrFail(); $oo->country()->save($o); } diff --git a/database/seeders/CurrencyTableSeeder.php b/database/seeders/CurrencyTableSeeder.php index 5585ca8..efddcb0 100644 --- a/database/seeders/CurrencyTableSeeder.php +++ b/database/seeders/CurrencyTableSeeder.php @@ -18,10 +18,10 @@ class CurrencyTableSeeder extends Seeder $o = new Currency; $o->id = 6; $o->name = 'Australian Dollars'; - $o->symbol = '$'; - $o->iso_code = 'AUD'; - $o->rounding = 2; $o->active = TRUE; + $o->symbol = '$'; + $o->iso = 'AUD'; + $o->rounding = 2; $o->save(); } } \ No newline at end of file diff --git a/database/seeders/SiteTableSeeder.php b/database/seeders/SiteTableSeeder.php index a44ffde..36b9885 100644 --- a/database/seeders/SiteTableSeeder.php +++ b/database/seeders/SiteTableSeeder.php @@ -18,7 +18,6 @@ class SiteTableSeeder extends Seeder // Test Sites 254 & 255 $o = new Site; $o->id = 254; - // $o->date_orig $o->active = TRUE; $o->site_id = 254; $o->country_id = 61; @@ -32,7 +31,6 @@ class SiteTableSeeder extends Seeder // Test Sites 254 & 255 $o = new Site; $o->id = 255; - // $o->date_orig $o->site_id = 255; $o->active = TRUE; $o->country_id = 61; diff --git a/database/seeders/UserTableSeeder.php b/database/seeders/UserTableSeeder.php index cb88f82..7d9f16b 100644 --- a/database/seeders/UserTableSeeder.php +++ b/database/seeders/UserTableSeeder.php @@ -17,10 +17,9 @@ class UserTableSeeder extends Seeder { $o = new User; $o->id = 1; - $o->site_id = 1; + $o->site_id = 254; $o->language_id = 1; $o->country_id = 61; - $o->currency_id = 6; $o->active = 1; $o->firstname = 'Wholesaler'; $o->lastname = 'User'; @@ -29,10 +28,9 @@ class UserTableSeeder extends Seeder $o = new User; $o->id = 10; - $o->site_id = 1; + $o->site_id = 254; $o->language_id = 1; $o->country_id = 61; - $o->currency_id = 6; $o->active = 1; $o->firstname = 'reseller1-0'; $o->lastname = 'User'; @@ -41,10 +39,9 @@ class UserTableSeeder extends Seeder $o = new User; $o->id = 11; - $o->site_id = 1; + $o->site_id = 254; $o->language_id = 1; $o->country_id = 61; - $o->currency_id = 6; $o->active = 1; $o->firstname = 'reseller2-0'; $o->lastname = 'User'; @@ -53,10 +50,9 @@ class UserTableSeeder extends Seeder $o = new User; $o->id = 110; - $o->site_id = 1; + $o->site_id = 254; $o->language_id = 1; $o->country_id = 61; - $o->currency_id = 6; $o->active = 1; $o->firstname = 'reseller2-1'; $o->lastname = 'User'; @@ -65,10 +61,9 @@ class UserTableSeeder extends Seeder $o = new User; $o->id = 1010; - $o->site_id = 1; + $o->site_id = 254; $o->language_id = 1; $o->country_id = 61; - $o->currency_id = 6; $o->active = 1; $o->firstname = 'user1-0-1'; $o->lastname = 'User'; @@ -77,10 +72,9 @@ class UserTableSeeder extends Seeder $o = new User; $o->id = 1110; - $o->site_id = 1; + $o->site_id = 254; $o->language_id = 1; $o->country_id = 61; - $o->currency_id = 6; $o->active = 1; $o->firstname = 'user2-1-1'; $o->lastname = 'User';