Changeset View
Changeset View
Standalone View
Standalone View
src/database/seeds/local/SkuSeeder.php
<?php | <?php | ||||
namespace Database\Seeds\Local; | namespace Database\Seeds\Local; | ||||
use App\Sku; | use App\Sku; | ||||
use Illuminate\Database\Seeder; | use Illuminate\Database\Seeder; | ||||
class SkuSeeder extends Seeder | class SkuSeeder extends Seeder | ||||
{ | { | ||||
/** | /** | ||||
* Run the database seeds. | * Run the database seeds. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function run() | public function run() | ||||
{ | { | ||||
Sku::create( | $skus = [ | ||||
[ | [ | ||||
'title' => 'mailbox', | 'title' => 'mailbox', | ||||
'name' => 'User Mailbox', | 'name' => 'User Mailbox', | ||||
'description' => 'Just a mailbox', | 'description' => 'Just a mailbox', | ||||
'cost' => 500, | 'cost' => 500, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Mailbox', | 'handler_class' => 'App\Handlers\Mailbox', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'domain', | 'title' => 'domain', | ||||
'name' => 'Hosted Domain', | 'name' => 'Hosted Domain', | ||||
'description' => 'Somewhere to place a mailbox', | 'description' => 'Somewhere to place a mailbox', | ||||
'cost' => 100, | 'cost' => 100, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Domain', | 'handler_class' => 'App\Handlers\Domain', | ||||
'active' => false, | 'active' => false, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'domain-registration', | 'title' => 'domain-registration', | ||||
'name' => 'Domain Registration', | 'name' => 'Domain Registration', | ||||
'description' => 'Register a domain with us', | 'description' => 'Register a domain with us', | ||||
'cost' => 101, | 'cost' => 101, | ||||
'period' => 'yearly', | 'period' => 'yearly', | ||||
'handler_class' => 'App\Handlers\DomainRegistration', | 'handler_class' => 'App\Handlers\DomainRegistration', | ||||
'active' => false, | 'active' => false, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'domain-hosting', | 'title' => 'domain-hosting', | ||||
'name' => 'External Domain', | 'name' => 'External Domain', | ||||
'description' => 'Host a domain that is externally registered', | 'description' => 'Host a domain that is externally registered', | ||||
'cost' => 100, | 'cost' => 100, | ||||
'units_free' => 1, | 'units_free' => 1, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\DomainHosting', | 'handler_class' => 'App\Handlers\DomainHosting', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'domain-relay', | 'title' => 'domain-relay', | ||||
'name' => 'Domain Relay', | 'name' => 'Domain Relay', | ||||
'description' => 'A domain you host at home, for which we relay email', | 'description' => 'A domain you host at home, for which we relay email', | ||||
'cost' => 103, | 'cost' => 103, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\DomainRelay', | 'handler_class' => 'App\Handlers\DomainRelay', | ||||
'active' => false, | 'active' => false, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'storage', | 'title' => 'storage', | ||||
'name' => 'Storage Quota', | 'name' => 'Storage Quota', | ||||
'description' => 'Some wiggle room', | 'description' => 'Some wiggle room', | ||||
'cost' => 25, | 'cost' => 25, | ||||
'units_free' => 5, | 'units_free' => 5, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Storage', | 'handler_class' => 'App\Handlers\Storage', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'groupware', | 'title' => 'groupware', | ||||
'name' => 'Groupware Features', | 'name' => 'Groupware Features', | ||||
'description' => 'Groupware functions like Calendar, Tasks, Notes, etc.', | 'description' => 'Groupware functions like Calendar, Tasks, Notes, etc.', | ||||
'cost' => 490, | 'cost' => 490, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Groupware', | 'handler_class' => 'App\Handlers\Groupware', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'resource', | 'title' => 'resource', | ||||
'name' => 'Resource', | 'name' => 'Resource', | ||||
'description' => 'Reservation taker', | 'description' => 'Reservation taker', | ||||
'cost' => 101, | 'cost' => 101, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Resource', | 'handler_class' => 'App\Handlers\Resource', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'shared-folder', | 'title' => 'shared-folder', | ||||
'name' => 'Shared Folder', | 'name' => 'Shared Folder', | ||||
'description' => 'A shared folder', | 'description' => 'A shared folder', | ||||
'cost' => 89, | 'cost' => 89, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\SharedFolder', | 'handler_class' => 'App\Handlers\SharedFolder', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => '2fa', | 'title' => '2fa', | ||||
'name' => '2-Factor Authentication', | 'name' => '2-Factor Authentication', | ||||
'description' => 'Two factor authentication for webmail and administration panel', | 'description' => 'Two factor authentication for webmail and administration panel', | ||||
'cost' => 0, | 'cost' => 0, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Auth2F', | 'handler_class' => 'App\Handlers\Auth2F', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'activesync', | 'title' => 'activesync', | ||||
'name' => 'Activesync', | 'name' => 'Activesync', | ||||
'description' => 'Mobile synchronization', | 'description' => 'Mobile synchronization', | ||||
'cost' => 0, | 'cost' => 0, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Activesync', | 'handler_class' => 'App\Handlers\Activesync', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
// Check existence because migration might have added this already | |||||
$sku = Sku::where(['title' => 'beta', 'tenant_id' => \config('app.tenant_id')])->first(); | |||||
if (!$sku) { | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'beta', | 'title' => 'beta', | ||||
'name' => 'Private Beta (invitation only)', | 'name' => 'Private Beta (invitation only)', | ||||
'description' => 'Access to the private beta program features', | 'description' => 'Access to the private beta program features', | ||||
'cost' => 0, | 'cost' => 0, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Beta', | 'handler_class' => 'App\Handlers\Beta', | ||||
'active' => false, | 'active' => false, | ||||
] | ], | ||||
); | |||||
} | |||||
// Check existence because migration might have added this already | |||||
$sku = Sku::where(['title' => 'meet', 'tenant_id' => \config('app.tenant_id')])->first(); | |||||
if (!$sku) { | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'meet', | 'title' => 'group', | ||||
'name' => 'Voice & Video Conferencing (public beta)', | 'name' => 'Group', | ||||
'description' => 'Video conferencing tool', | 'description' => 'Distribution list', | ||||
'cost' => 0, | 'cost' => 0, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Meet', | 'handler_class' => 'App\Handlers\Group', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
} | |||||
// Check existence because migration might have added this already | |||||
$sku = Sku::where(['title' => 'group', 'tenant_id' => \config('app.tenant_id')])->first(); | |||||
if (!$sku) { | |||||
Sku::create( | |||||
[ | [ | ||||
'title' => 'group', | 'title' => 'group-room', | ||||
'name' => 'Group', | 'name' => 'Group conference room', | ||||
'description' => 'Distribution list', | 'description' => 'Shareable audio & video conference room', | ||||
'cost' => 0, | 'cost' => 0, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Group', | 'handler_class' => 'App\Handlers\GroupRoom', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | [ | ||||
} | 'title' => 'room', | ||||
'name' => 'Standard conference room', | |||||
'description' => 'Audio & video conference room', | |||||
'cost' => 0, | |||||
'units_free' => 0, | |||||
'period' => 'monthly', | |||||
'handler_class' => 'App\Handlers\Room', | |||||
'active' => true, | |||||
], | |||||
]; | |||||
// for tenants that are not the configured tenant id | foreach ($skus as $sku) { | ||||
$tenants = \App\Tenant::where('id', '!=', \config('app.tenant_id'))->get(); | // Check existence because migration might have added this already | ||||
if (!Sku::where('title', $sku['title'])->where('tenant_id', \config('app.tenant_id'))->first()) { | |||||
Sku::create($sku); | |||||
} | |||||
} | |||||
foreach ($tenants as $tenant) { | $skus = [ | ||||
$sku = Sku::create( | |||||
[ | [ | ||||
'title' => 'mailbox', | 'title' => 'mailbox', | ||||
'name' => 'User Mailbox', | 'name' => 'User Mailbox', | ||||
'description' => 'Just a mailbox', | 'description' => 'Just a mailbox', | ||||
'cost' => 500, | 'cost' => 500, | ||||
'fee' => 333, | 'fee' => 333, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Mailbox', | 'handler_class' => 'App\Handlers\Mailbox', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
$sku->tenant_id = $tenant->id; | |||||
$sku->save(); | |||||
$sku = Sku::create( | |||||
[ | [ | ||||
'title' => 'storage', | 'title' => 'storage', | ||||
'name' => 'Storage Quota', | 'name' => 'Storage Quota', | ||||
'description' => 'Some wiggle room', | 'description' => 'Some wiggle room', | ||||
'cost' => 25, | 'cost' => 25, | ||||
'fee' => 16, | 'fee' => 16, | ||||
'units_free' => 5, | 'units_free' => 5, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Storage', | 'handler_class' => 'App\Handlers\Storage', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
$sku->tenant_id = $tenant->id; | |||||
$sku->save(); | |||||
$sku = Sku::create( | |||||
[ | [ | ||||
'title' => 'domain-hosting', | 'title' => 'domain-hosting', | ||||
'name' => 'External Domain', | 'name' => 'External Domain', | ||||
'description' => 'Host a domain that is externally registered', | 'description' => 'Host a domain that is externally registered', | ||||
'cost' => 100, | 'cost' => 100, | ||||
'fee' => 66, | 'fee' => 66, | ||||
'units_free' => 1, | 'units_free' => 1, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\DomainHosting', | 'handler_class' => 'App\Handlers\DomainHosting', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
$sku->tenant_id = $tenant->id; | |||||
$sku->save(); | |||||
$sku = Sku::create( | |||||
[ | [ | ||||
'title' => 'groupware', | 'title' => 'groupware', | ||||
'name' => 'Groupware Features', | 'name' => 'Groupware Features', | ||||
'description' => 'Groupware functions like Calendar, Tasks, Notes, etc.', | 'description' => 'Groupware functions like Calendar, Tasks, Notes, etc.', | ||||
'cost' => 490, | 'cost' => 490, | ||||
'fee' => 327, | 'fee' => 327, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Groupware', | 'handler_class' => 'App\Handlers\Groupware', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
$sku->tenant_id = $tenant->id; | |||||
$sku->save(); | |||||
$sku = Sku::create( | |||||
[ | [ | ||||
'title' => '2fa', | 'title' => '2fa', | ||||
'name' => '2-Factor Authentication', | 'name' => '2-Factor Authentication', | ||||
'description' => 'Two factor authentication for webmail and administration panel', | 'description' => 'Two factor authentication for webmail and administration panel', | ||||
'cost' => 0, | 'cost' => 0, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Auth2F', | 'handler_class' => 'App\Handlers\Auth2F', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | |||||
$sku->tenant_id = $tenant->id; | |||||
$sku->save(); | |||||
$sku = Sku::create( | |||||
[ | [ | ||||
'title' => 'activesync', | 'title' => 'activesync', | ||||
'name' => 'Activesync', | 'name' => 'Activesync', | ||||
'description' => 'Mobile synchronization', | 'description' => 'Mobile synchronization', | ||||
'cost' => 0, | 'cost' => 0, | ||||
'units_free' => 0, | 'units_free' => 0, | ||||
'period' => 'monthly', | 'period' => 'monthly', | ||||
'handler_class' => 'App\Handlers\Activesync', | 'handler_class' => 'App\Handlers\Activesync', | ||||
'active' => true, | 'active' => true, | ||||
] | ], | ||||
); | ]; | ||||
// for tenants that are not the configured tenant id | |||||
$tenants = \App\Tenant::where('id', '!=', \config('app.tenant_id'))->get(); | |||||
foreach ($tenants as $tenant) { | |||||
foreach ($skus as $sku) { | |||||
$sku = Sku::create($sku); | |||||
$sku->tenant_id = $tenant->id; | $sku->tenant_id = $tenant->id; | ||||
$sku->save(); | $sku->save(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} |