fixed tenants and eventpurchaseresource, changed lightbox in gallery
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('tenants')
|
||||
->select('id', 'name')
|
||||
->orderBy('id')
|
||||
->chunkById(100, function ($tenants): void {
|
||||
foreach ($tenants as $tenant) {
|
||||
$raw = $tenant->name;
|
||||
|
||||
if ($raw === null || $raw === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$decoded = json_decode($raw, true);
|
||||
$value = $raw;
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
||||
$preferred = $decoded['de'] ?? $decoded['en'] ?? null;
|
||||
|
||||
if ($preferred === null) {
|
||||
foreach ($decoded as $entry) {
|
||||
if (is_string($entry) && $entry !== '') {
|
||||
$preferred = $entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$value = $preferred ?? (string) $raw;
|
||||
}
|
||||
|
||||
DB::table('tenants')->where('id', $tenant->id)->update([
|
||||
'name' => (string) $value,
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('tenants')
|
||||
->select('id', 'name')
|
||||
->orderBy('id')
|
||||
->chunkById(100, function ($tenants): void {
|
||||
foreach ($tenants as $tenant) {
|
||||
$raw = $tenant->name;
|
||||
|
||||
if ($raw === null || $raw === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$localized = json_encode([
|
||||
'de' => $raw,
|
||||
'en' => $raw,
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
DB::table('tenants')->where('id', $tenant->id)->update([
|
||||
'name' => $localized,
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -13,7 +13,7 @@ class TasksSeeder extends Seeder
|
||||
$demoTenant = \App\Models\Tenant::updateOrCreate(
|
||||
['slug' => 'demo'],
|
||||
[
|
||||
'name' => ['de' => 'Demo Tenant', 'en' => 'Demo Tenant'],
|
||||
'name' => 'Demo Tenant',
|
||||
'domain' => null,
|
||||
'is_active' => true,
|
||||
'settings' => [],
|
||||
@@ -58,4 +58,3 @@ class TasksSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user