feat(tenant): implement TenantProvisioningService and OnTicketTenantSeeder for tenant management
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Database\Seeders\OnTicketTenantSeeder;
|
||||
use Database\Seeders\WebsiteTypeSeeder;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
private const TENANT_CODE = 'onticket';
|
||||
|
||||
private const EXCLUDED_MENU_CODES = [
|
||||
'product.detail',
|
||||
'help',
|
||||
'help.faq',
|
||||
'help.contact',
|
||||
'help.payment-methods',
|
||||
'help.shipping',
|
||||
'help.terms-and-conditions',
|
||||
'adminapp.tickets',
|
||||
'adminapp.fiesta-futbol-infantil.entradas',
|
||||
'adminapp.fiesta-futbol-infantil.alojamientos',
|
||||
'adminapp.fiesta-futbol-infantil.merchandising',
|
||||
'adminapp.fiesta-futbol-infantil.comida',
|
||||
'adminapp.desfile.entradas',
|
||||
];
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
if (app()->environment('testing')) {
|
||||
Storage::fake('s3');
|
||||
}
|
||||
|
||||
app(WebsiteTypeSeeder::class)->run();
|
||||
app(OnTicketTenantSeeder::class)->run();
|
||||
|
||||
$now = now();
|
||||
|
||||
DB::table('menues')
|
||||
->whereNotIn('code', self::EXCLUDED_MENU_CODES)
|
||||
->pluck('code')
|
||||
->each(function (string $menuCode) use ($now): void {
|
||||
DB::table('tenants_menues')->updateOrInsert(
|
||||
[
|
||||
'tenant_code' => self::TENANT_CODE,
|
||||
'menu_code' => $menuCode,
|
||||
],
|
||||
[
|
||||
'static_content' => null,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// OnTicket is reference data. Never remove a possibly active tenant on rollback.
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user