Commit 8a304674 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(feat): Footer settings

1 merge request!281WIP: (feat): Minds Pro
Pipeline #74206828 passed with stages
in 9 minutes and 58 seconds
......@@ -196,6 +196,27 @@ class Manager
->setPlainBackgroundColor($values['plain_background_color']);
}
if (isset($values['footer_text'])) {
// TODO: Validate!
$settings
->setFooterText($values['footer_text']);
}
if (isset($values['footer_links']) && is_array($values['footer_links'])) {
$footerLinks = array_map(function ($item) {
$href = $item['href'];
$title = ($item['title'] ?? null) ?: $item['href'];
return compact('title', 'href');
}, array_filter($values['footer_links'], function ($item) {
return $item && $item['href'] && filter_var($item['href'], FILTER_VALIDATE_URL);
}));
$settings
->setFooterLinks(array_values($footerLinks));
}
return $this->repository->update($settings);
}
}
......@@ -92,7 +92,9 @@ class Repository
->setHeadline($data['headline'] ?? '')
->setTextColor($data['text_color'] ?? '')
->setPrimaryColor($data['primary_color'] ?? '')
->setPlainBackgroundColor($data['plain_background_color'] ?? '');
->setPlainBackgroundColor($data['plain_background_color'] ?? '')
->setFooterText($data['footer_text'] ?? '')
->setFooterLinks($data['footer_links'] ?? []);
$response[] = $settings;
}
......@@ -132,6 +134,8 @@ class Repository
'text_color' => $settings->getTextColor(),
'primary_color' => $settings->getPrimaryColor(),
'plain_background_color' => $settings->getPlainBackgroundColor(),
'footer_text' => $settings->getFooterText(),
'footer_links' => $settings->getFooterLinks(),
]),
];
......
......@@ -26,6 +26,10 @@ use Minds\Traits\MagicAttributes;
* @method Settings setPrimaryColor(string $primaryColor)
* @method string getPlainBackgroundColor()
* @method Settings setPlainBackgroundColor(string $plainBackgroundColor)
* @method string getFooterText()
* @method Settings setFooterText(string $footerText)
* @method array getFooterLinks()
* @method Settings setFooterLinks(array $footerLinks)
* @method string getBackgroundImage()
* @method Settings setBackgroundImage(string $backgroundImage)
* @method string getLogoImage()
......@@ -35,6 +39,12 @@ class Settings implements JsonSerializable
{
use MagicAttributes;
const DEFAULT_TEXT_COLOR = '#000000';
const DEFAULT_PRIMARY_COLOR = '#4690df';
const DEFAULT_PLAIN_BACKGROUND_COLOR = '#ffffff';
/** @var int */
protected $userGuid;
......@@ -62,6 +72,12 @@ class Settings implements JsonSerializable
/** @var string */
protected $logoImage;
/** @var string */
protected $footerText;
/** @var array */
protected $footerLinks = [];
/**
* @return array
*/
......@@ -72,15 +88,17 @@ class Settings implements JsonSerializable
'domain' => $this->domain,
'title' => $this->title,
'headline' => $this->headline,
'text_color' => $this->textColor,
'primary_color' => $this->primaryColor,
'plain_background_color' => $this->plainBackgroundColor,
'text_color' => $this->textColor ?: static::DEFAULT_TEXT_COLOR,
'primary_color' => $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR,
'plain_background_color' => $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR,
'footer_text' => $this->footerText,
'footer_links' => $this->footerLinks,
'background_image' => $this->backgroundImage,
'logo_image' => $this->logoImage,
'styles' => [
'text_color' => $this->textColor ?: '#000000',
'primary_color' => $this->primaryColor ?: '#4690df',
'plain_background_color' => $this->plainBackgroundColor ?: '#ffffff',
'text_color' => $this->textColor ?: static::DEFAULT_TEXT_COLOR,
'primary_color' => $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR,
'plain_background_color' => $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR,
],
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment