UI and editing updates
This commit is contained in:
@@ -50,9 +50,13 @@ final class InstallSaaslandContent extends Command
|
||||
]
|
||||
);
|
||||
|
||||
if ((int) $document->content_type_id !== (int) $type->id) {
|
||||
$document->forceFill(['content_type_id' => $type->id])->save();
|
||||
}
|
||||
$currentData = is_array($document->data) ? $document->data : [];
|
||||
$mergedData = $this->mergeMissingDefaults($currentData, $definition['data']);
|
||||
|
||||
$document->forceFill([
|
||||
'content_type_id' => $type->id,
|
||||
'data' => $mergedData,
|
||||
])->save();
|
||||
[$region, $sort] = $order[$key];
|
||||
PageContent::query()->updateOrCreate(
|
||||
['page_key' => 'home', 'region' => $region, 'sort_order' => $sort],
|
||||
@@ -65,6 +69,30 @@ final class InstallSaaslandContent extends Command
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function mergeMissingDefaults(array $current, array $defaults): array
|
||||
{
|
||||
foreach ($defaults as $key => $defaultValue) {
|
||||
if (! array_key_exists($key, $current)) {
|
||||
$current[$key] = $defaultValue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
is_array($defaultValue)
|
||||
&& is_array($current[$key])
|
||||
&& ! array_is_list($defaultValue)
|
||||
&& ! array_is_list($current[$key])
|
||||
) {
|
||||
$current[$key] = $this->mergeMissingDefaults(
|
||||
$current[$key],
|
||||
$defaultValue
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
|
||||
private function definitions(): array
|
||||
{
|
||||
$field = static fn (string $key, string $label, string $type = 'text', array $extra = []): array => array_merge(compact('key', 'label', 'type'), $extra);
|
||||
@@ -84,11 +112,45 @@ final class InstallSaaslandContent extends Command
|
||||
'site-header' => [
|
||||
'title' => 'Main website header',
|
||||
'type' => $type('Site header', 'site-header', ['header'], [
|
||||
...$section, $field('show_navigation', 'Show navigation', 'boolean', ['default' => true]), $field('show_login', 'Show login', 'boolean', ['default' => true]),
|
||||
$field('show_registration', 'Show registration', 'boolean', ['default' => true]), $field('login_label', 'Login label'),
|
||||
$field('registration_label', 'Registration label'), $field('sticky', 'Sticky header', 'boolean', ['default' => true]),
|
||||
$field('enabled', 'Show header', 'boolean', ['default' => true]),
|
||||
$field('brand_text', 'Brand text'),
|
||||
$field('brand_url', 'Brand URL', 'url'),
|
||||
$field('logo_url', 'Logo URL', 'url'),
|
||||
$field('show_navigation', 'Show navigation', 'boolean', ['default' => true]),
|
||||
$field('links', 'Navigation links', 'repeater', ['fields' => [
|
||||
$field('enabled', 'Show link', 'boolean', ['default' => true]),
|
||||
$field('label', 'Label'),
|
||||
$field('url', 'URL', 'url'),
|
||||
]]),
|
||||
$field('show_dashboard', 'Show dashboard link', 'boolean', ['default' => true]),
|
||||
$field('dashboard_label', 'Dashboard label'),
|
||||
$field('show_user_name', 'Show signed-in user', 'boolean', ['default' => true]),
|
||||
$field('show_login', 'Show login', 'boolean', ['default' => true]),
|
||||
$field('login_label', 'Login label'),
|
||||
$field('show_registration', 'Show registration', 'boolean', ['default' => true]),
|
||||
$field('registration_label', 'Registration label'),
|
||||
$field('show_mobile_menu', 'Show mobile menu', 'boolean', ['default' => true]),
|
||||
]),
|
||||
'data' => ['enabled' => true, 'show_navigation' => true, 'show_login' => true, 'show_registration' => true, 'login_label' => 'Log in', 'registration_label' => 'Get started', 'sticky' => true],
|
||||
'data' => [
|
||||
'enabled' => true,
|
||||
'brand_text' => config('app.name'),
|
||||
'brand_url' => '/',
|
||||
'logo_url' => '',
|
||||
'show_navigation' => true,
|
||||
'links' => [
|
||||
['enabled' => true, 'label' => 'Home', 'url' => '/'],
|
||||
['enabled' => true, 'label' => 'Blog', 'url' => '/blog'],
|
||||
['enabled' => true, 'label' => 'News', 'url' => '/news'],
|
||||
],
|
||||
'show_dashboard' => true,
|
||||
'dashboard_label' => 'Dashboard',
|
||||
'show_user_name' => true,
|
||||
'show_login' => true,
|
||||
'login_label' => 'Log in',
|
||||
'show_registration' => true,
|
||||
'registration_label' => 'Get started',
|
||||
'show_mobile_menu' => true,
|
||||
],
|
||||
],
|
||||
'hero' => [
|
||||
'title' => 'Homepage hero',
|
||||
@@ -140,9 +202,48 @@ final class InstallSaaslandContent extends Command
|
||||
],
|
||||
'site-footer' => [
|
||||
'title' => 'Main website footer',
|
||||
'type' => $type('Site footer', 'site-footer', ['footer'], [...$section, $field('description', 'Description', 'textarea'), $field('show_navigation', 'Show footer navigation', 'boolean'), $field('show_account_links', 'Show account links', 'boolean', ['default' => true]), $field('show_social_links', 'Show social links', 'boolean', ['default' => true]), $field('show_back_to_top', 'Show back-to-top link', 'boolean', ['default' => true]), $field('copyright', 'Copyright text')]),
|
||||
'data' => ['enabled' => true, 'description' => 'One connected platform for modern teams.', 'show_navigation' => true, 'show_account_links' => true, 'show_social_links' => true, 'show_back_to_top' => true, 'copyright' => 'All rights reserved.'],
|
||||
'type' => $type('Site footer', 'site-footer', ['footer'], [
|
||||
$field('enabled', 'Show footer', 'boolean', ['default' => true]),
|
||||
$field('brand_text', 'Brand text'),
|
||||
$field('brand_url', 'Brand URL', 'url'),
|
||||
$field('description', 'Description', 'textarea'),
|
||||
$field('columns', 'Footer columns', 'repeater', ['fields' => [
|
||||
$field('enabled', 'Show column', 'boolean', ['default' => true]),
|
||||
$field('heading', 'Heading'),
|
||||
$field('links', 'Links', 'repeater', ['fields' => [
|
||||
$field('enabled', 'Show link', 'boolean', ['default' => true]),
|
||||
$field('label', 'Label'),
|
||||
$field('url', 'URL', 'url'),
|
||||
]]),
|
||||
]]),
|
||||
$field('copyright', 'Copyright text'),
|
||||
$field('show_back_to_top', 'Show back-to-top link', 'boolean', ['default' => true]),
|
||||
$field('back_to_top_label', 'Back-to-top label'),
|
||||
]),
|
||||
'data' => [
|
||||
'enabled' => true,
|
||||
'brand_text' => config('app.name'),
|
||||
'brand_url' => '/',
|
||||
'description' => 'Software and services built for modern organisations.',
|
||||
'columns' => [
|
||||
['enabled' => true, 'heading' => 'Explore', 'links' => [
|
||||
['enabled' => true, 'label' => 'Home', 'url' => '/'],
|
||||
['enabled' => true, 'label' => 'Blog', 'url' => '/blog'],
|
||||
['enabled' => true, 'label' => 'News', 'url' => '/news'],
|
||||
]],
|
||||
['enabled' => true, 'heading' => 'Account', 'links' => [
|
||||
['enabled' => true, 'label' => 'Dashboard', 'url' => '/dashboard'],
|
||||
['enabled' => true, 'label' => 'Profile', 'url' => '/settings/profile'],
|
||||
]],
|
||||
['enabled' => true, 'heading' => 'Connect', 'links' => [
|
||||
['enabled' => true, 'label' => 'Contact', 'url' => '/contact'],
|
||||
]],
|
||||
],
|
||||
'copyright' => '© '.date('Y').' '.config('app.name').'. All rights reserved.',
|
||||
'show_back_to_top' => true,
|
||||
'back_to_top_label' => 'Back to top ↑',
|
||||
],
|
||||
],
|
||||
];
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user