diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 6b901f8..9751776 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -21,5 +21,7 @@ class DatabaseSeeder extends Seeder 'name' => 'Test User', 'email' => 'test@example.com', ]); + + $this->call(TenantSeeder::class); } } diff --git a/database/seeders/TenantSeeder.php b/database/seeders/TenantSeeder.php new file mode 100644 index 0000000..1794e21 --- /dev/null +++ b/database/seeders/TenantSeeder.php @@ -0,0 +1,82 @@ +where('codigo', 'sonder')->first(); + if ($existing) { + $attachmentService = app(\App\Domains\Attachable\Services\AttachmentService::class); + if ($existing->headerLogo) { + try { + $attachmentService->delete($existing->headerLogo); + } catch (\Throwable $e) { + // Ignore exception on cleanup + } + } + if ($existing->footerLogo && $existing->footer_logo_id !== $existing->header_logo_id) { + try { + $attachmentService->delete($existing->footerLogo); + } catch (\Throwable $e) { + // Ignore exception on cleanup + } + } + $existing->delete(); + } + + // Check if domain 'localhost' is already in use by another tenant and delete it + $existingDomain = Tenant::query()->where('dominio', 'localhost')->first(); + if ($existingDomain) { + $existingDomain->delete(); + } + + $imagePath = public_path('images/sonder.png'); + + if (! file_exists($imagePath)) { + throw new \RuntimeException("Image not found at path: {$imagePath}"); + } + + $headerLogo = new UploadedFile( + $imagePath, + 'sonder.png', + 'image/png', + null, + true + ); + + $footerLogo = new UploadedFile( + $imagePath, + 'sonder.png', + 'image/png', + null, + true + ); + + $this->tenantService->create([ + 'codigo' => 'sonder', + 'nombre' => 'Sonder', + 'dominio' => 'localhost', + 'primary_color' => '#6376F3', + 'secondary_color' => '#A0A0A0', + 'danger_color' => '#FF8888', + 'header_footer_bg_color' => '#313131', + 'header_logo' => $headerLogo, + 'footer_logo' => $footerLogo, + ]); + } +} diff --git a/public/images/sonder.png b/public/images/sonder.png new file mode 100644 index 0000000..07c045e Binary files /dev/null and b/public/images/sonder.png differ