structure changes
This commit is contained in:
@@ -8,6 +8,8 @@ use Illuminate\Support\Facades\Schema;
|
||||
use Modules\Content\Models\ContentDocument;
|
||||
use Modules\Content\Models\ContentType;
|
||||
use Modules\Content\Models\PageContent;
|
||||
use Modules\Menus\Models\Menu;
|
||||
use Modules\Settings\Services\SettingsRepository;
|
||||
|
||||
final class InstallSaaslandContent extends Command
|
||||
{
|
||||
@@ -26,6 +28,8 @@ final class InstallSaaslandContent extends Command
|
||||
}
|
||||
|
||||
DB::transaction(function (): void {
|
||||
$this->installSharedSettings();
|
||||
$this->installMenus();
|
||||
if ($this->option('force')) {
|
||||
PageContent::query()->where('page_key', 'home')->delete();
|
||||
}
|
||||
@@ -69,6 +73,55 @@ final class InstallSaaslandContent extends Command
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function installSharedSettings(): void
|
||||
{
|
||||
$settings = app(SettingsRepository::class);
|
||||
$legacy = [];
|
||||
|
||||
if (Schema::hasTable('stylist_theme_settings')) {
|
||||
$stored = DB::table('stylist_theme_settings')->where('theme_key', 'saasland')->value('settings');
|
||||
$legacy = is_string($stored) ? (json_decode($stored, true) ?: []) : [];
|
||||
}
|
||||
|
||||
$defaults = [
|
||||
'site_name' => $legacy['site_title'] ?? config('app.name'),
|
||||
'site_description' => $legacy['site_description'] ?? 'Modern software for modern companies.',
|
||||
'company_name' => $legacy['site_title'] ?? config('app.name'),
|
||||
'site_url' => url('/'),
|
||||
'logo_url' => $legacy['logo_url'] ?? '',
|
||||
'facebook_url' => $legacy['facebook_url'] ?? '',
|
||||
'x_url' => $legacy['x_url'] ?? '',
|
||||
'linkedin_url' => $legacy['linkedin_url'] ?? '',
|
||||
'dashboard_label' => 'Dashboard',
|
||||
'login_label' => 'Log in',
|
||||
'registration_label' => 'Get started',
|
||||
];
|
||||
|
||||
foreach ($defaults as $key => $value) {
|
||||
if ($settings->get($key, null, 'site') === null) {
|
||||
$settings->put($key, $value, 'site', 'string', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function installMenus(): void
|
||||
{
|
||||
if (! Schema::hasTable('menus')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$menus = [
|
||||
'primary' => ['Primary navigation', [['enabled' => true, 'label' => 'Home', 'url' => '/'], ['enabled' => true, 'label' => 'Blog', 'url' => '/blog'], ['enabled' => true, 'label' => 'News', 'url' => '/news']]],
|
||||
'footer' => ['Footer — Explore', [['enabled' => true, 'label' => 'Home', 'url' => '/'], ['enabled' => true, 'label' => 'Blog', 'url' => '/blog'], ['enabled' => true, 'label' => 'News', 'url' => '/news']]],
|
||||
'footer_account' => ['Footer — Account', [['enabled' => true, 'label' => 'Dashboard', 'url' => '/dashboard'], ['enabled' => true, 'label' => 'Profile', 'url' => '/settings/profile']]],
|
||||
'footer_legal' => ['Footer — Legal', []],
|
||||
];
|
||||
|
||||
foreach ($menus as $location => [$name, $items]) {
|
||||
Menu::query()->firstOrCreate(['location' => $location], ['name' => $name, 'items' => $items, 'enabled' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
private function mergeMissingDefaults(array $current, array $defaults): array
|
||||
{
|
||||
foreach ($defaults as $key => $defaultValue) {
|
||||
@@ -113,44 +166,15 @@ final class InstallSaaslandContent extends Command
|
||||
'title' => 'Main website header',
|
||||
'type' => $type('Site header', 'site-header', ['header'], [
|
||||
$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('menu_location', 'Navigation menu location', 'text', ['help' => 'Usually primary. Edit links from Administration → Menus.']),
|
||||
$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,
|
||||
'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,
|
||||
],
|
||||
'data' => ['enabled' => true, 'menu_location' => 'primary', 'show_navigation' => true, 'show_dashboard' => true, 'show_user_name' => true, 'show_login' => true, 'show_registration' => true, 'show_mobile_menu' => true],
|
||||
],
|
||||
'hero' => [
|
||||
'title' => 'Homepage hero',
|
||||
@@ -204,46 +228,17 @@ final class InstallSaaslandContent extends Command
|
||||
'title' => 'Main website footer',
|
||||
'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('explore_heading', 'Explore column heading'),
|
||||
$field('explore_menu_location', 'Explore menu location'),
|
||||
$field('account_heading', 'Account column heading'),
|
||||
$field('account_menu_location', 'Account menu location'),
|
||||
$field('legal_heading', 'Legal column heading'),
|
||||
$field('legal_menu_location', 'Legal menu location'),
|
||||
$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 ↑',
|
||||
],
|
||||
'data' => ['enabled' => true, 'explore_heading' => 'Explore', 'explore_menu_location' => 'footer', 'account_heading' => 'Account', 'account_menu_location' => 'footer_account', 'legal_heading' => 'Legal', 'legal_menu_location' => 'footer_legal', 'show_back_to_top' => true, 'back_to_top_label' => 'Back to top ↑'],
|
||||
],
|
||||
];
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user