feat: add hero background image functionality to Tenant model and related requests, resources, and seeder
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('hero_bg_image_id')
|
||||
->virtualAs('hero_config->>"$.background_image_id"')
|
||||
->nullable()
|
||||
->after('footer_bg_color');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropColumn('hero_bg_image_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -100,6 +100,11 @@ class TenantSeeder extends Seeder
|
||||
$attachmentService->delete($existingFiesta->footerLogo);
|
||||
} catch (\Throwable $e) {}
|
||||
}
|
||||
if ($existingFiesta->heroBgImage) {
|
||||
try {
|
||||
$attachmentService->delete($existingFiesta->heroBgImage);
|
||||
} catch (\Throwable $e) {}
|
||||
}
|
||||
$existingFiesta->delete();
|
||||
}
|
||||
|
||||
@@ -111,6 +116,7 @@ class TenantSeeder extends Seeder
|
||||
|
||||
$fiestaHeaderImagePath = public_path('images/futbol_infantil_header.png');
|
||||
$fiestaFooterImagePath = public_path('images/futbol_infantil_footer.png');
|
||||
$fiestaHeroBgImagePath = public_path('images/futbol_infantil_hero.jpg');
|
||||
|
||||
if (! file_exists($fiestaHeaderImagePath)) {
|
||||
throw new \RuntimeException("Image not found at path: {$fiestaHeaderImagePath}");
|
||||
@@ -120,6 +126,10 @@ class TenantSeeder extends Seeder
|
||||
throw new \RuntimeException("Image not found at path: {$fiestaFooterImagePath}");
|
||||
}
|
||||
|
||||
if (! file_exists($fiestaHeroBgImagePath)) {
|
||||
throw new \RuntimeException("Image not found at path: {$fiestaHeroBgImagePath}");
|
||||
}
|
||||
|
||||
$fiestaHeaderLogo = new UploadedFile(
|
||||
$fiestaHeaderImagePath,
|
||||
'futbol_infantil_header.png',
|
||||
@@ -136,6 +146,14 @@ class TenantSeeder extends Seeder
|
||||
true
|
||||
);
|
||||
|
||||
$fiestaHeroBgImage = new UploadedFile(
|
||||
$fiestaHeroBgImagePath,
|
||||
'futbol_infantil_hero.jpg',
|
||||
'image/jpeg',
|
||||
null,
|
||||
true
|
||||
);
|
||||
|
||||
$this->tenantService->create([
|
||||
'codigo' => 'fiesta_futbol_infantil',
|
||||
'nombre' => 'Fiesta Fútbol Infantil',
|
||||
@@ -148,6 +166,7 @@ class TenantSeeder extends Seeder
|
||||
'footer_bg_color' => '#015327',
|
||||
'header_logo' => $fiestaHeaderLogo,
|
||||
'footer_logo' => $fiestaFooterLogo,
|
||||
'hero_bg_image' => $fiestaHeroBgImage,
|
||||
'hero_config' => [
|
||||
'title_html' => '<strong>ASEGURÁ TU LUGAR</strong>',
|
||||
'description_html' => '<strong>Comprá tu entrada oficial en segundos</strong> de forma 100% segura. Preparate para vivir la experiencia completa.',
|
||||
|
||||
Reference in New Issue
Block a user