feat: add hero_config and event_config to Tenant model with validation and migration
This commit is contained in:
@@ -22,6 +22,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
'footer_bg_color',
|
'footer_bg_color',
|
||||||
'header_logo_id',
|
'header_logo_id',
|
||||||
'footer_logo_id',
|
'footer_logo_id',
|
||||||
|
'hero_config',
|
||||||
|
'event_config',
|
||||||
])]
|
])]
|
||||||
class Tenant extends Model
|
class Tenant extends Model
|
||||||
{
|
{
|
||||||
@@ -32,6 +34,19 @@ class Tenant extends Model
|
|||||||
return 'codigo';
|
return 'codigo';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'hero_config' => 'array',
|
||||||
|
'event_config' => 'array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Attachment, $this>
|
* @return BelongsTo<Attachment, $this>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,6 +61,17 @@ class StoreTenantRequest extends FormRequest
|
|||||||
'footer_bg_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
'footer_bg_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
'header_logo' => $logoRule,
|
'header_logo' => $logoRule,
|
||||||
'footer_logo' => $logoRule,
|
'footer_logo' => $logoRule,
|
||||||
|
'hero_config' => ['nullable', 'array'],
|
||||||
|
'hero_config.background_image' => ['nullable', 'string'],
|
||||||
|
'hero_config.title_html' => ['nullable', 'string'],
|
||||||
|
'hero_config.description_html' => ['nullable', 'string'],
|
||||||
|
'hero_config.button_text' => ['nullable', 'string'],
|
||||||
|
'hero_config.button_href' => ['nullable', 'string'],
|
||||||
|
'event_config' => ['nullable', 'array'],
|
||||||
|
'event_config.title' => ['nullable', 'string'],
|
||||||
|
'event_config.location' => ['nullable', 'string'],
|
||||||
|
'event_config.dates' => ['nullable', 'array'],
|
||||||
|
'event_config.dates.*' => ['required', 'string'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,17 @@ class UpdateTenantRequest extends FormRequest
|
|||||||
'footer_bg_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
'footer_bg_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
'header_logo' => $logoRule,
|
'header_logo' => $logoRule,
|
||||||
'footer_logo' => $logoRule,
|
'footer_logo' => $logoRule,
|
||||||
|
'hero_config' => ['nullable', 'array'],
|
||||||
|
'hero_config.background_image' => ['nullable', 'string'],
|
||||||
|
'hero_config.title_html' => ['nullable', 'string'],
|
||||||
|
'hero_config.description_html' => ['nullable', 'string'],
|
||||||
|
'hero_config.button_text' => ['nullable', 'string'],
|
||||||
|
'hero_config.button_href' => ['nullable', 'string'],
|
||||||
|
'event_config' => ['nullable', 'array'],
|
||||||
|
'event_config.title' => ['nullable', 'string'],
|
||||||
|
'event_config.location' => ['nullable', 'string'],
|
||||||
|
'event_config.dates' => ['nullable', 'array'],
|
||||||
|
'event_config.dates.*' => ['required', 'string'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class TenantResource extends JsonResource
|
|||||||
// 1 day
|
// 1 day
|
||||||
'header_logo' => $this->headerLogo?->getTemporaryUrl(1440),
|
'header_logo' => $this->headerLogo?->getTemporaryUrl(1440),
|
||||||
'footer_logo' => $this->footerLogo?->getTemporaryUrl(1440 ),
|
'footer_logo' => $this->footerLogo?->getTemporaryUrl(1440 ),
|
||||||
|
'hero_config' => $this->hero_config,
|
||||||
|
'event_config' => $this->event_config,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?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->json('hero_config')->nullable();
|
||||||
|
$table->json('event_config')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('tenants', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['hero_config', 'event_config']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user