From 67bc9e6cb4b5fd29104482141b113b2e33c3ef45 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Mon, 29 Jun 2026 09:32:09 -0300 Subject: [PATCH] feat: add DatabaseSeeder and TenantSeeder with sample tenant configuration and assets --- database/seeders/DatabaseSeeder.php | 2 + database/seeders/TenantSeeder.php | 82 ++++++++++++++++++++++++++++ public/images/sonder.png | Bin 0 -> 1363 bytes 3 files changed, 84 insertions(+) create mode 100644 database/seeders/TenantSeeder.php create mode 100644 public/images/sonder.png 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 0000000000000000000000000000000000000000..07c045e08f63faa9b22eeb9d37a040cde8895607 GIT binary patch literal 1363 zcmV-Z1+4msP);&}&SDm2l1XU(zI)S}G zoC%^%&~9L5g1Qq>nIPT(1xo0MWg7X4Rq9NK4Jz*IvQO)h)g42R`BGE0r9F`{)E;tQn@GF^wW8w!o zQ+>fJV&-4afUl@nd$%5m_Tc>CULhZIkBpQbqy*{XBl*(~GJ(!aFT6hbe)gJQ7XC`) z_j>P2WWFY3L03ZmdR4z6h&6DCQw~5pZNRgX%l&~M*_8`CqObG%T@!6G`Bxd%!S=fy zoqzt7;N7wg!n=s@+(h(QOZ}6`jL{Zdd|?vLG!}bUPtRJbmpUWzd_2K9L6o$Zk4kx{ z6mF%B1|Ddm=+t02Sk8RnGci^enao6gzu=sJ(*~{-sU3WOM4ea;TLFvHpy}CL2Mz5k zbC8Yv4a*RrFYWjz$7hKQ8|m`_hJKmP_r)QYw~_j<5Z5(^_rAWQS3|{@fafPTKi9_x z|3h3K4IR-Pxbt~U^r^7DhUVEFbY|#YRz_?UyaX0K-w?CV;x5GM+y@)7ml!4QD?;!##UzAnpWELzO6KR{f z7#QkN?<%-v^U;9|iTfjg0T)Ie`dP@imK1NP{LcE33EYEjI=@34Y|?Ha zAACe>p%A1SZw5BWsj*@Uq}|^`KEBB~9Lk3R$ZGJ3Vc^i0`v2c0y6Z@x_d)+`CdUT7 z5!nZ3h5Cv<3-!wjr!?B*GjWT$&%CC(CL&AYKPDbXcBNHZ@s^eUeS#pB80e(@dmz_V zM+h0nFiEe1`rF8=<(&~*-8GbBOwSIU>osY2z5#5s2GgN>F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