diff --git a/phpcs.xml b/phpcs.xml
index b0749e63..35571e9b 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,12 +1,13 @@
Custom ruleset for Kolab
src/app/
src/tests/
+ src/database/
diff --git a/src/database/migrations/2014_10_12_100000_create_password_resets_table.php b/src/database/migrations/2014_10_12_100000_create_password_resets_table.php
index 0d5cb845..044ea83d 100644
--- a/src/database/migrations/2014_10_12_100000_create_password_resets_table.php
+++ b/src/database/migrations/2014_10_12_100000_create_password_resets_table.php
@@ -1,32 +1,33 @@
string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
diff --git a/src/database/migrations/2019_09_17_102626_create_wallet_table.php b/src/database/migrations/2019_09_17_102626_create_wallet_table.php
index 872fe4e3..681c9ba7 100644
--- a/src/database/migrations/2019_09_17_102626_create_wallet_table.php
+++ b/src/database/migrations/2019_09_17_102626_create_wallet_table.php
@@ -1,42 +1,43 @@
string('id', 36);
$table->string('description', 128)->nullable();
$table->string('currency', 4);
$table->integer('balance');
$table->bigInteger('user_id');
$table->primary('id');
$table->index('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('wallets');
}
}
diff --git a/src/database/migrations/2019_09_17_102627_wallet_controllers.php b/src/database/migrations/2019_09_17_102627_wallet_controllers.php
index 941b9ea9..57bcb2a8 100644
--- a/src/database/migrations/2019_09_17_102627_wallet_controllers.php
+++ b/src/database/migrations/2019_09_17_102627_wallet_controllers.php
@@ -1,40 +1,41 @@
bigIncrements('id');
$table->bigInteger('user_id');
$table->string('wallet_id', 36);
$table->timestamps();
$table->unique(['user_id', 'wallet_id']);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('wallet_id')->references('id')->on('wallets')->onDelete('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_accounts');
}
}
diff --git a/src/database/migrations/2019_09_17_105606_create_jobs_table.php b/src/database/migrations/2019_09_17_105606_create_jobs_table.php
index 58d77154..440fd502 100644
--- a/src/database/migrations/2019_09_17_105606_create_jobs_table.php
+++ b/src/database/migrations/2019_09_17_105606_create_jobs_table.php
@@ -1,36 +1,37 @@
bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}
diff --git a/src/database/migrations/2019_09_17_132012_create_user_settings_table.php b/src/database/migrations/2019_09_17_132012_create_user_settings_table.php
index b6b2c2b4..7203506e 100644
--- a/src/database/migrations/2019_09_17_132012_create_user_settings_table.php
+++ b/src/database/migrations/2019_09_17_132012_create_user_settings_table.php
@@ -1,42 +1,43 @@
bigIncrements('id');
$table->bigInteger('user_id');
$table->string('key');
$table->string('value');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')
->onDelete('cascade')->onUpdate('cascade');
$table->unique(['user_id', 'key']);
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_settings');
}
}
diff --git a/src/database/migrations/2019_09_23_071701_create_domains_table.php b/src/database/migrations/2019_09_23_071701_create_domains_table.php
index 06399128..616e324c 100644
--- a/src/database/migrations/2019_09_23_071701_create_domains_table.php
+++ b/src/database/migrations/2019_09_23_071701_create_domains_table.php
@@ -1,34 +1,35 @@
bigInteger('id');
$table->string('namespace')->unique();
$table->smallinteger('status');
$table->tinyinteger('type');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('domains');
}
}
diff --git a/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php b/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php
index 08043edb..219feaba 100644
--- a/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php
+++ b/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php
@@ -1,34 +1,35 @@
string('code', 32);
$table->string('short_code', 8);
$table->text('data');
$table->timestamp('expires_at');
$table->primary('code');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('signup_codes');
}
}
diff --git a/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php b/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php
index d432dff0..c72b1d78 100644
--- a/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php
+++ b/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php
@@ -1,35 +1,36 @@
bigIncrements('id');
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}
diff --git a/src/database/migrations/2019_10_10_095050_create_quota_table.php b/src/database/migrations/2019_10_10_095050_create_quota_table.php
index 67650dba..2aa97bcd 100644
--- a/src/database/migrations/2019_10_10_095050_create_quota_table.php
+++ b/src/database/migrations/2019_10_10_095050_create_quota_table.php
@@ -1,37 +1,38 @@
bigIncrements('id');
$table->bigInteger('user_id');
$table->unsignedInteger('value')->default(2147483648);
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
*/
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('quotas');
}
}
diff --git a/src/database/migrations/2019_12_10_095027_create_packages_table.php b/src/database/migrations/2019_12_10_095027_create_packages_table.php
index d7544346..f70ba550 100644
--- a/src/database/migrations/2019_12_10_095027_create_packages_table.php
+++ b/src/database/migrations/2019_12_10_095027_create_packages_table.php
@@ -1,39 +1,40 @@
string('id', 36);
$table->string('title', 36);
$table->json('name');
$table->json('description');
$table->integer('discount_rate')->default(0)->nullable();
$table->primary('id');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('packages');
}
}
diff --git a/src/database/migrations/2019_12_10_105428_create_plans_table.php b/src/database/migrations/2019_12_10_105428_create_plans_table.php
index f6d596ee..e756f52b 100644
--- a/src/database/migrations/2019_12_10_105428_create_plans_table.php
+++ b/src/database/migrations/2019_12_10_105428_create_plans_table.php
@@ -1,44 +1,45 @@
string('id', 36);
$table->string('title', 36);
$table->json('name');
$table->json('description');
$table->datetime('promo_from')->nullable();
$table->datetime('promo_to')->nullable();
$table->integer('qty_min')->default(0)->nullable();
$table->integer('qty_max')->default(0)->nullable();
$table->integer('discount_qty')->default(0);
$table->integer('discount_rate')->default(0);
$table->primary('id');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('plans');
}
}
diff --git a/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php b/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php
index 2e2e0cdd..3c2bcafc 100644
--- a/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php
+++ b/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php
@@ -1,48 +1,49 @@
bigIncrements('id');
$table->string('plan_id', 36);
$table->string('package_id', 36);
$table->integer('qty')->default(1);
$table->integer('qty_min')->default(0);
$table->integer('qty_max')->default(0);
$table->integer('discount_qty')->default(0);
$table->integer('discount_rate')->default(0);
$table->foreign('plan_id')->references('id')->on('plans')
->onDelete('cascade')->onUpdate('cascade');
$table->foreign('package_id')->references('id')->on('packages')
->onDelete('cascade')->onUpdate('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('plan_packages');
}
}
diff --git a/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php b/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php
index e8daf8c6..cc3a2ae5 100644
--- a/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php
+++ b/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php
@@ -1,37 +1,38 @@
bigInteger('user_id');
$table->string('code', 32);
$table->string('short_code', 16);
$table->string('mode');
$table->timestamp('expires_at');
$table->primary('code');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('verification_codes');
}
}
diff --git a/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php b/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php
index bfa07e6b..62f7c7e4 100644
--- a/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php
+++ b/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php
@@ -1,39 +1,40 @@
bigIncrements('id');
$table->bigInteger('user_id');
$table->string('alias')->unique();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')
->onDelete('cascade')->onUpdate('cascade');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_aliases');
}
}
diff --git a/src/database/migrations/2020_04_21_100000_create_wallet_settings.php b/src/database/migrations/2020_04_21_100000_create_wallet_settings.php
index 309680ef..b0792113 100644
--- a/src/database/migrations/2020_04_21_100000_create_wallet_settings.php
+++ b/src/database/migrations/2020_04_21_100000_create_wallet_settings.php
@@ -1,40 +1,41 @@
bigIncrements('id');
$table->string('wallet_id');
$table->string('key');
$table->string('value');
$table->timestamps();
$table->foreign('wallet_id')->references('id')->on('wallets')->onDelete('cascade');
$table->unique(['wallet_id', 'key']);
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('wallet_settings');
}
}
diff --git a/src/database/seeds/DatabaseSeeder.php b/src/database/seeds/DatabaseSeeder.php
index 83e2c649..1e5e3db7 100644
--- a/src/database/seeds/DatabaseSeeder.php
+++ b/src/database/seeds/DatabaseSeeder.php
@@ -1,25 +1,37 @@
call(
- [
- DiscountSeeder::class,
- DomainSeeder::class,
- SkuSeeder::class,
- PackageSeeder::class,
- PlanSeeder::class,
- UserSeeder::class
- ]
- );
+ // Define seeders order
+ $seeders = [
+ 'DiscountSeeder',
+ 'DomainSeeder',
+ 'SkuSeeder',
+ 'PackageSeeder',
+ 'PlanSeeder',
+ 'UserSeeder'
+ ];
+
+ $env = ucfirst(App::environment());
+
+ // Check if the seeders exists
+ foreach ($seeders as $idx => $name) {
+ $class = "Database\\Seeds\\$env\\$name";
+ $seeders[$idx] = class_exists($class) ? $class : null;
+ }
+
+ $seeders = array_filter($seeders);
+
+ $this->call($seeders);
}
}
diff --git a/src/database/seeds/DiscountSeeder.php b/src/database/seeds/local/DiscountSeeder.php
similarity index 96%
copy from src/database/seeds/DiscountSeeder.php
copy to src/database/seeds/local/DiscountSeeder.php
index b23266cd..7862bdb5 100644
--- a/src/database/seeds/DiscountSeeder.php
+++ b/src/database/seeds/local/DiscountSeeder.php
@@ -1,40 +1,42 @@
'Free Account',
'discount' => 100,
'active' => true,
]
);
Discount::create(
[
'description' => 'Student or Educational Institution',
'discount' => 30,
'active' => true,
]
);
Discount::create(
[
'description' => 'Test voucher',
'discount' => 10,
'active' => true,
'code' => 'TEST',
]
);
}
}
diff --git a/src/database/seeds/DomainSeeder.php b/src/database/seeds/local/DomainSeeder.php
similarity index 98%
copy from src/database/seeds/DomainSeeder.php
copy to src/database/seeds/local/DomainSeeder.php
index d21e4890..4e02e668 100644
--- a/src/database/seeds/DomainSeeder.php
+++ b/src/database/seeds/local/DomainSeeder.php
@@ -1,65 +1,67 @@
$domain,
'status' => Domain::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
'type' => Domain::TYPE_PUBLIC
]
);
}
if (!in_array(\config('app.domain'), $domains)) {
Domain::create(
[
'namespace' => \config('app.domain'),
'status' => DOMAIN::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
'type' => Domain::TYPE_PUBLIC
]
);
}
$domains = [
'example.com',
'example.net',
'example.org'
];
foreach ($domains as $domain) {
Domain::create(
[
'namespace' => $domain,
'status' => Domain::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
'type' => Domain::TYPE_EXTERNAL
]
);
}
}
}
diff --git a/src/database/seeds/PackageSeeder.php b/src/database/seeds/local/PackageSeeder.php
similarity index 98%
copy from src/database/seeds/PackageSeeder.php
copy to src/database/seeds/local/PackageSeeder.php
index 6dec592a..a5bb1b4a 100644
--- a/src/database/seeds/PackageSeeder.php
+++ b/src/database/seeds/local/PackageSeeder.php
@@ -1,83 +1,84 @@
'groupware']);
$skuMailbox = Sku::firstOrCreate(['title' => 'mailbox']);
$skuStorage = Sku::firstOrCreate(['title' => 'storage']);
$package = Package::create(
[
'title' => 'kolab',
'name' => 'Groupware Account',
'description' => 'A fully functional groupware account.',
'discount_rate' => 0
]
);
$skus = [
$skuMailbox,
$skuGroupware,
$skuStorage
];
$package->skus()->saveMany($skus);
// This package contains 2 units of the storage SKU, which just so happens to also
// be the number of SKU free units.
$package->skus()->updateExistingPivot(
$skuStorage,
['qty' => 2],
false
);
$package = Package::create(
[
'title' => 'lite',
'name' => 'Lite Account',
'description' => 'Just mail and no more.',
'discount_rate' => 0
]
);
$skus = [
$skuMailbox,
$skuStorage
];
$package->skus()->saveMany($skus);
$package->skus()->updateExistingPivot(
Sku::firstOrCreate(['title' => 'storage']),
['qty' => 2],
false
);
$package = Package::create(
[
'title' => 'domain-hosting',
'name' => 'Domain Hosting',
'description' => 'Use your own, existing domain.',
'discount_rate' => 0
]
);
$skus = [
Sku::firstOrCreate(['title' => 'domain-hosting'])
];
$package->skus()->saveMany($skus);
}
}
diff --git a/src/database/seeds/PlanSeeder.php b/src/database/seeds/local/PlanSeeder.php
similarity index 99%
rename from src/database/seeds/PlanSeeder.php
rename to src/database/seeds/local/PlanSeeder.php
index 49cb03d0..a696e6b2 100644
--- a/src/database/seeds/PlanSeeder.php
+++ b/src/database/seeds/local/PlanSeeder.php
@@ -1,168 +1,169 @@
'family',
'description' => 'A group of accounts for 2 or more users.',
'discount_qty' => 0,
'discount_rate' => 0
]
);
$packages = [
Package::firstOrCreate(['title' => 'kolab']),
Package::firstOrCreate(['title' => 'domain-hosting'])
];
$plan->packages()->saveMany($packages);
$plan->packages()->updateExistingPivot(
Package::firstOrCreate(['title' => 'kolab']),
[
'qty_min' => 2,
'qty_max' => -1,
'discount_qty' => 2,
'discount_rate' => 50
],
false
);
$plan = Plan::create(
[
'title' => 'small-business',
'description' => 'Accounts for small business owners.',
'discount_qty' => 0,
'discount_rate' => 10
]
);
$packages = [
Package::firstOrCreate(['title' => 'kolab']),
Package::firstOrCreate(['title' => 'domain-hosting'])
];
$plan->packages()->saveMany($packages);
$plan->packages()->updateExistingPivot(
Package::firstOrCreate(['title' => 'kolab']),
[
'qty_min' => 5,
'qty_max' => 25,
'discount_qty' => 5,
'discount_rate' => 30
],
false
);
$plan = Plan::create(
[
'title' => 'large-business',
'description' => 'Accounts for large businesses.',
'discount_qty' => 0,
'discount_rate' => 10
]
);
$packages = [
Package::firstOrCreate(['title' => 'kolab']),
Package::firstOrCreate(['title' => 'lite']),
Package::firstOrCreate(['title' => 'domain-hosting'])
];
$plan->packages()->saveMany($packages);
$plan->packages()->updateExistingPivot(
Package::firstOrCreate(['title' => 'kolab']),
[
'qty_min' => 20,
'qty_max' => -1,
'discount_qty' => 10,
'discount_rate' => 10
],
false
);
$plan->packages()->updateExistingPivot(
Package::firstOrCreate(['title' => 'lite']),
[
'qty_min' => 0,
'qty_max' => -1,
'discount_qty' => 10,
'discount_rate' => 10
],
false
);
*/
$description = <<<'EOD'
Everything you need to get started or try Kolab Now, including:
- Perfect for anyone wanting to move to Kolab Now
- Suite of online apps: Secure email, calendar, address book, files and more
- Access for anywhere: Sync all your devices to your Kolab Now account
- Secure hosting: Managed right here on our own servers in Switzerland
- Start protecting your data today, no ads, no crawling, no compromise
- An ideal replacement for services like Gmail, Office 365, etc…
EOD;
$plan = Plan::create(
[
'title' => 'individual',
'name' => 'Individual Account',
'description' => $description,
'discount_qty' => 0,
'discount_rate' => 0
]
);
$packages = [
Package::firstOrCreate(['title' => 'kolab'])
];
$plan->packages()->saveMany($packages);
$description = <<<'EOD'
All the features of the Individual Account, with the following extras:
- Perfect for anyone wanting to move a group or small business to Kolab Now
- Recommended to support users from 1 to 100
- Use your own personal domains with Kolab Now
- Manage and add users through our online admin area
- Flexible pricing based on user count
EOD;
$plan = Plan::create(
[
'title' => 'group',
'name' => 'Group Account',
'description' => $description,
'discount_qty' => 0,
'discount_rate' => 0
]
);
$packages = [
Package::firstOrCreate(['title' => 'domain-hosting']),
Package::firstOrCreate(['title' => 'kolab']),
];
$plan->packages()->saveMany($packages);
}
}
diff --git a/src/database/seeds/SkuSeeder.php b/src/database/seeds/local/SkuSeeder.php
similarity index 99%
copy from src/database/seeds/SkuSeeder.php
copy to src/database/seeds/local/SkuSeeder.php
index 287fd205..e3b49179 100644
--- a/src/database/seeds/SkuSeeder.php
+++ b/src/database/seeds/local/SkuSeeder.php
@@ -1,153 +1,155 @@
'mailbox',
'name' => 'User Mailbox',
'description' => 'Just a mailbox',
'cost' => 444,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Mailbox',
'active' => true,
]
);
Sku::create(
[
'title' => 'domain',
'name' => 'Hosted Domain',
'description' => 'Somewhere to place a mailbox',
'cost' => 100,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Domain',
'active' => false,
]
);
Sku::create(
[
'title' => 'domain-registration',
'name' => 'Domain Registration',
'description' => 'Register a domain with us',
'cost' => 101,
'period' => 'yearly',
'handler_class' => 'App\Handlers\DomainRegistration',
'active' => false,
]
);
Sku::create(
[
'title' => 'domain-hosting',
'name' => 'External Domain',
'description' => 'Host a domain that is externally registered',
'cost' => 100,
'units_free' => 1,
'period' => 'monthly',
'handler_class' => 'App\Handlers\DomainHosting',
'active' => true,
]
);
Sku::create(
[
'title' => 'domain-relay',
'name' => 'Domain Relay',
'description' => 'A domain you host at home, for which we relay email',
'cost' => 103,
'period' => 'monthly',
'handler_class' => 'App\Handlers\DomainRelay',
'active' => false,
]
);
Sku::create(
[
'title' => 'storage',
'name' => 'Storage Quota',
'description' => 'Some wiggle room',
'cost' => 25,
'units_free' => 2,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Storage',
'active' => true,
]
);
Sku::create(
[
'title' => 'groupware',
'name' => 'Groupware Features',
'description' => 'Groupware functions like Calendar, Tasks, Notes, etc.',
'cost' => 555,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Groupware',
'active' => true,
]
);
Sku::create(
[
'title' => 'resource',
'name' => 'Resource',
'description' => 'Reservation taker',
'cost' => 101,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Resource',
'active' => false,
]
);
Sku::create(
[
'title' => 'shared_folder',
'name' => 'Shared Folder',
'description' => 'A shared folder',
'cost' => 89,
'period' => 'monthly',
'handler_class' => 'App\Handlers\SharedFolder',
'active' => false,
]
);
Sku::create(
[
'title' => '2fa',
'name' => '2-Factor Authentication',
'description' => 'Two factor authentication for webmail and administration panel',
'cost' => 0,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Auth2F',
'active' => true,
]
);
Sku::create(
[
'title' => 'activesync',
'name' => 'Activesync',
'description' => 'Mobile synchronization',
'cost' => 100,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Activesync',
'active' => true,
]
);
}
}
diff --git a/src/database/seeds/UserSeeder.php b/src/database/seeds/local/UserSeeder.php
similarity index 99%
rename from src/database/seeds/UserSeeder.php
rename to src/database/seeds/local/UserSeeder.php
index ab98806a..f36dde3c 100644
--- a/src/database/seeds/UserSeeder.php
+++ b/src/database/seeds/local/UserSeeder.php
@@ -1,140 +1,141 @@
'kolab.org',
'status' => Domain::STATUS_NEW
+ Domain::STATUS_ACTIVE
+ Domain::STATUS_CONFIRMED
+ Domain::STATUS_VERIFIED,
'type' => Domain::TYPE_EXTERNAL
]
);
$john = User::create(
[
'email' => 'john@kolab.org',
'password' => 'simple123',
]
);
$john->setSettings(
[
'first_name' => 'John',
'last_name' => 'Doe',
'currency' => 'USD',
'country' => 'US',
'billing_address' => "601 13th Street NW\nSuite 900 South\nWashington, DC 20005",
'external_email' => 'john.doe.external@gmail.com',
'organization' => 'Kolab Developers',
'phone' => '+1 509-248-1111',
]
);
$john->setAliases(['john.doe@kolab.org']);
$wallet = $john->wallets->first();
$package_domain = \App\Package::where('title', 'domain-hosting')->first();
$package_kolab = \App\Package::where('title', 'kolab')->first();
$package_lite = \App\Package::where('title', 'lite')->first();
$domain->assignPackage($package_domain, $john);
$john->assignPackage($package_kolab);
$jack = User::create(
[
'email' => 'jack@kolab.org',
'password' => 'simple123',
]
);
$jack->setSettings(
[
'first_name' => 'Jack',
'last_name' => 'Daniels',
'currency' => 'USD',
'country' => 'US'
]
);
$jack->setAliases(['jack.daniels@kolab.org']);
$john->assignPackage($package_kolab, $jack);
foreach ($john->entitlements as $entitlement) {
$entitlement->created_at = Carbon::now()->subMonthsWithoutOverflow(1);
$entitlement->updated_at = Carbon::now()->subMonthsWithoutOverflow(1);
$entitlement->save();
}
$ned = User::create(
[
'email' => 'ned@kolab.org',
'password' => 'simple123',
]
);
$ned->setSettings(
[
'first_name' => 'Edward',
'last_name' => 'Flanders',
'currency' => 'USD',
'country' => 'US'
]
);
$john->assignPackage($package_kolab, $ned);
$ned->assignSku(\App\Sku::where('title', 'activesync')->first(), 1);
// Ned is a controller on Jack's wallet
$john->wallets()->first()->addController($ned);
// Ned is also our 2FA test user
$sku2fa = Sku::firstOrCreate(['title' => '2fa']);
$ned->assignSku($sku2fa);
SecondFactor::seed('ned@kolab.org');
$joe = User::create(
[
'email' => 'joe@kolab.org',
'password' => 'simple123',
]
);
$john->assignPackage($package_lite, $joe);
factory(User::class, 10)->create();
$jeroen = User::create(
[
'email' => 'jeroen@jeroen.jeroen',
'password' => 'jeroen',
]
);
$jeroen->role = "admin";
$jeroen->save();
}
}
diff --git a/src/database/seeds/DiscountSeeder.php b/src/database/seeds/production/DiscountSeeder.php
similarity index 73%
rename from src/database/seeds/DiscountSeeder.php
rename to src/database/seeds/production/DiscountSeeder.php
index b23266cd..d5b83872 100644
--- a/src/database/seeds/DiscountSeeder.php
+++ b/src/database/seeds/production/DiscountSeeder.php
@@ -1,40 +1,33 @@
'Free Account',
'discount' => 100,
'active' => true,
]
);
Discount::create(
[
'description' => 'Student or Educational Institution',
'discount' => 30,
'active' => true,
]
);
-
- Discount::create(
- [
- 'description' => 'Test voucher',
- 'discount' => 10,
- 'active' => true,
- 'code' => 'TEST',
- ]
- );
}
}
diff --git a/src/database/seeds/DomainSeeder.php b/src/database/seeds/production/DomainSeeder.php
similarity index 51%
rename from src/database/seeds/DomainSeeder.php
rename to src/database/seeds/production/DomainSeeder.php
index d21e4890..59f8ee5e 100644
--- a/src/database/seeds/DomainSeeder.php
+++ b/src/database/seeds/production/DomainSeeder.php
@@ -1,65 +1,52 @@
$domain,
'status' => Domain::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
'type' => Domain::TYPE_PUBLIC
]
);
}
-
- if (!in_array(\config('app.domain'), $domains)) {
- Domain::create(
- [
- 'namespace' => \config('app.domain'),
- 'status' => DOMAIN::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
- 'type' => Domain::TYPE_PUBLIC
- ]
- );
- }
-
- $domains = [
- 'example.com',
- 'example.net',
- 'example.org'
- ];
-
- foreach ($domains as $domain) {
- Domain::create(
- [
- 'namespace' => $domain,
- 'status' => Domain::STATUS_CONFIRMED + Domain::STATUS_ACTIVE,
- 'type' => Domain::TYPE_EXTERNAL
- ]
- );
- }
}
}
diff --git a/src/database/seeds/PackageSeeder.php b/src/database/seeds/production/PackageSeeder.php
similarity index 98%
rename from src/database/seeds/PackageSeeder.php
rename to src/database/seeds/production/PackageSeeder.php
index 6dec592a..e1287cfa 100644
--- a/src/database/seeds/PackageSeeder.php
+++ b/src/database/seeds/production/PackageSeeder.php
@@ -1,83 +1,84 @@
'groupware']);
$skuMailbox = Sku::firstOrCreate(['title' => 'mailbox']);
$skuStorage = Sku::firstOrCreate(['title' => 'storage']);
$package = Package::create(
[
'title' => 'kolab',
'name' => 'Groupware Account',
'description' => 'A fully functional groupware account.',
'discount_rate' => 0
]
);
$skus = [
$skuMailbox,
$skuGroupware,
$skuStorage
];
$package->skus()->saveMany($skus);
// This package contains 2 units of the storage SKU, which just so happens to also
// be the number of SKU free units.
$package->skus()->updateExistingPivot(
$skuStorage,
['qty' => 2],
false
);
$package = Package::create(
[
'title' => 'lite',
'name' => 'Lite Account',
'description' => 'Just mail and no more.',
'discount_rate' => 0
]
);
$skus = [
$skuMailbox,
$skuStorage
];
$package->skus()->saveMany($skus);
$package->skus()->updateExistingPivot(
Sku::firstOrCreate(['title' => 'storage']),
['qty' => 2],
false
);
$package = Package::create(
[
'title' => 'domain-hosting',
'name' => 'Domain Hosting',
'description' => 'Use your own, existing domain.',
'discount_rate' => 0
]
);
$skus = [
Sku::firstOrCreate(['title' => 'domain-hosting'])
];
$package->skus()->saveMany($skus);
}
}
diff --git a/src/database/seeds/production/PlanSeeder.php b/src/database/seeds/production/PlanSeeder.php
new file mode 100644
index 00000000..d3c979a0
--- /dev/null
+++ b/src/database/seeds/production/PlanSeeder.php
@@ -0,0 +1,74 @@
+Everything you need to get started or try Kolab Now, including:
+
+ - Perfect for anyone wanting to move to Kolab Now
+ - Suite of online apps: Secure email, calendar, address book, files and more
+ - Access for anywhere: Sync all your devices to your Kolab Now account
+ - Secure hosting: Managed right here on our own servers in Switzerland
+ - Start protecting your data today, no ads, no crawling, no compromise
+ - An ideal replacement for services like Gmail, Office 365, etc…
+
+EOD;
+
+ $plan = Plan::create(
+ [
+ 'title' => 'individual',
+ 'name' => 'Individual Account',
+ 'description' => $description,
+ 'discount_qty' => 0,
+ 'discount_rate' => 0
+ ]
+ );
+
+ $packages = [
+ Package::firstOrCreate(['title' => 'kolab'])
+ ];
+
+ $plan->packages()->saveMany($packages);
+
+ $description = <<<'EOD'
+All the features of the Individual Account, with the following extras:
+
+ - Perfect for anyone wanting to move a group or small business to Kolab Now
+ - Recommended to support users from 1 to 100
+ - Use your own personal domains with Kolab Now
+ - Manage and add users through our online admin area
+ - Flexible pricing based on user count
+
+EOD;
+
+ $plan = Plan::create(
+ [
+ 'title' => 'group',
+ 'name' => 'Group Account',
+ 'description' => $description,
+ 'discount_qty' => 0,
+ 'discount_rate' => 0
+ ]
+ );
+
+ $packages = [
+ Package::firstOrCreate(['title' => 'domain-hosting']),
+ Package::firstOrCreate(['title' => 'kolab']),
+ ];
+
+ $plan->packages()->saveMany($packages);
+ }
+}
diff --git a/src/database/seeds/SkuSeeder.php b/src/database/seeds/production/SkuSeeder.php
similarity index 98%
rename from src/database/seeds/SkuSeeder.php
rename to src/database/seeds/production/SkuSeeder.php
index 287fd205..c5142773 100644
--- a/src/database/seeds/SkuSeeder.php
+++ b/src/database/seeds/production/SkuSeeder.php
@@ -1,153 +1,155 @@
'mailbox',
'name' => 'User Mailbox',
'description' => 'Just a mailbox',
'cost' => 444,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Mailbox',
'active' => true,
]
);
Sku::create(
[
'title' => 'domain',
'name' => 'Hosted Domain',
'description' => 'Somewhere to place a mailbox',
'cost' => 100,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Domain',
'active' => false,
]
);
Sku::create(
[
'title' => 'domain-registration',
'name' => 'Domain Registration',
'description' => 'Register a domain with us',
'cost' => 101,
'period' => 'yearly',
'handler_class' => 'App\Handlers\DomainRegistration',
'active' => false,
]
);
Sku::create(
[
'title' => 'domain-hosting',
'name' => 'External Domain',
'description' => 'Host a domain that is externally registered',
'cost' => 100,
'units_free' => 1,
'period' => 'monthly',
'handler_class' => 'App\Handlers\DomainHosting',
'active' => true,
]
);
Sku::create(
[
'title' => 'domain-relay',
'name' => 'Domain Relay',
'description' => 'A domain you host at home, for which we relay email',
'cost' => 103,
'period' => 'monthly',
'handler_class' => 'App\Handlers\DomainRelay',
'active' => false,
]
);
Sku::create(
[
'title' => 'storage',
'name' => 'Storage Quota',
'description' => 'Some wiggle room',
- 'cost' => 25,
+ 'cost' => 50,
'units_free' => 2,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Storage',
'active' => true,
]
);
Sku::create(
[
'title' => 'groupware',
'name' => 'Groupware Features',
'description' => 'Groupware functions like Calendar, Tasks, Notes, etc.',
'cost' => 555,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Groupware',
'active' => true,
]
);
Sku::create(
[
'title' => 'resource',
'name' => 'Resource',
'description' => 'Reservation taker',
'cost' => 101,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Resource',
'active' => false,
]
);
Sku::create(
[
'title' => 'shared_folder',
'name' => 'Shared Folder',
'description' => 'A shared folder',
'cost' => 89,
'period' => 'monthly',
'handler_class' => 'App\Handlers\SharedFolder',
'active' => false,
]
);
Sku::create(
[
'title' => '2fa',
'name' => '2-Factor Authentication',
'description' => 'Two factor authentication for webmail and administration panel',
'cost' => 0,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Auth2F',
'active' => true,
]
);
Sku::create(
[
'title' => 'activesync',
'name' => 'Activesync',
'description' => 'Mobile synchronization',
'cost' => 100,
'units_free' => 0,
'period' => 'monthly',
'handler_class' => 'App\Handlers\Activesync',
'active' => true,
]
);
}
}