feat(brand): update footer color mapping and adjust tests
This commit is contained in:
@@ -18,13 +18,33 @@ class BrandResource extends JsonResource
|
||||
'nombre' => $this->nombre,
|
||||
'primary_color' => $this->primary_color,
|
||||
'header_bg_color' => $this->header_bg_color,
|
||||
'footer_bg_color' => $this->footer_bg_color,
|
||||
'footer_color' => $this->footerColor(),
|
||||
'header_logo' => $this->headerLogo?->getTemporaryUrl(1440),
|
||||
'footer_logo' => $this->footerLogo?->getTemporaryUrl(1440),
|
||||
'banner_images' => $this->bannerImages(),
|
||||
];
|
||||
}
|
||||
|
||||
private function footerColor(): string
|
||||
{
|
||||
$footerColor = strtolower(trim((string) $this->footer_bg_color));
|
||||
$primaryColor = strtolower(trim((string) $this->primary_color));
|
||||
|
||||
if ($footerColor !== '' && $footerColor === $primaryColor) {
|
||||
return 'primary';
|
||||
}
|
||||
|
||||
if (in_array($footerColor, ['#000', '#000000', 'black'], true)) {
|
||||
return 'black';
|
||||
}
|
||||
|
||||
if ($footerColor === '' || in_array($footerColor, ['#fff', '#ffffff', 'white'], true)) {
|
||||
return 'white';
|
||||
}
|
||||
|
||||
return 'primary';
|
||||
}
|
||||
|
||||
/** @return array<int, array<string, mixed>> */
|
||||
private function bannerImages(): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user