HEX
Server: nginx/1.28.3
System: Linux lightweb-s1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User: drdrivek-71 (1047)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/dnlightw-124/dn.lightweb.kr/app/Providers/SettingsServiceProvider.php
<?php
namespace App\Providers;

use App\Settings\Configs\ConfigGroup;
use App\Settings\Configs\SiteConfigHandler;
use App\Settings\Extends\Layouts\VueComponentLayout;
use Orchid\Platform\Dashboard;
use Orchid\Platform\ItemPermission;
use Orchid\Platform\OrchidServiceProvider;
use Orchid\Screen\Actions\Menu;
use App\Settings\Asides\MenuItems;
use Illuminate\Support\Facades\Route;

use App\Settings\Commands\AdminCommand;
use App\Settings\Commands\PresenterCommand;
use App\Settings\Commands\RowsCommand;
use App\Settings\Commands\ScreenCommand;
use App\Settings\Commands\CmsEntity;
use App\Services\CmsHelper;
use App\Services\CmsPermission;
use Orchid\Screen\LayoutFactory;

class SettingsServiceProvider extends OrchidServiceProvider
{
    public function register(): void
    {
        parent::register();
        LayoutFactory::macro('vue', function ($view, $data = []) {
            return new class($view, $data) extends VueComponentLayout {};
        });
        $this->loadJsonTranslationsFrom(app_path('Settings/resources/lang'));
        $this->loadViewsFrom(app_path('Settings/resources/views'), 'settings');
        $this->loadViewsFrom(app_path('Settings/resources/views'), 'platform');

        if ($this->app->runningInConsole()) {
            $this->commands([
                AdminCommand::class,
                // ChartCommand::class,
                // FilterCommand::class,
                // ListenerCommand::class,
                PresenterCommand::class,
                RowsCommand::class,
                // SelectionCommand::class,
                // TableCommand::class,
                // TabMenuCommand::class,
                ScreenCommand::class,
                CmsEntity::class,
            ]);
        }
    }

    /**
     * Bootstrap the application services.
     *
     * @param Dashboard $dashboard
     *
     * @return void
     */
    public function boot(Dashboard $dashboard): void
    {
        $this->setIntegrationKeys();
        $this->setSEOConfigs();
        $this->setThemeConfigs();
        $this->registerRoutes();
        parent::boot($dashboard);
    }

    /**
     * Register the application menu.
     *
     * @return Menu[]
     */
    public function menu(): array
    {
        return (new MenuItems)->mainMenu();
    }

    /**
     * Register permissions for the application.
     *
     * @return ItemPermission[]
     */
    public function permissions(): array
    {
        $permissionGroups = [];
        foreach(CmsHelper::getEntities() as $entity){
            if(!method_exists($entity['class'], 'getPermissions')) continue;

            $permissions = $entity['class']::getPermissions();
            foreach($permissions as $cmsPermission){
                if(!$cmsPermission instanceof CmsPermission) continue;

                if(!isset($permissionGroups[$cmsPermission->getGroup()])) $permissionGroups[$cmsPermission->getGroup()] = ItemPermission::group($cmsPermission->getGroup());
                $permissionGroups[$cmsPermission->getGroup()]->addPermission($cmsPermission->getSlug(), __($cmsPermission->getLabel()));
            }
        }

        $permissionGroups[ConfigGroup::CONFIG_GROUP_NAME] = ItemPermission::group(ConfigGroup::CONFIG_GROUP_NAME);
        $permissionGroups[ConfigGroup::CONFIG_GROUP_NAME]->addPermission('settings.site_configs', __('Site Configs'));
        foreach(SiteConfigHandler::getConfigGroups() as $group){
            $cmsPermission = $group->getPermission();
            if(!$cmsPermission instanceof CmsPermission) continue;

            $permissionGroups[$cmsPermission->getGroup()]->addPermission($cmsPermission->getSlug(), __($cmsPermission->getLabel()));
        }

        // analytics
        $permissionGroups['analytics-screen'] = ItemPermission::group('analytics-screen');
        $permissionGroups['analytics-screen']->addPermission('settings.google_analytics', __('Google Analytics'));

        return $permissionGroups;
    }

    public function registerRoutes(): void
    {
        Route::domain((string) config('platform.domain'))
                    ->prefix(Dashboard::prefix('/'))
                    ->middleware(config('platform.middleware.private'))
                    ->name('settings.')
                    ->group(app_path('Settings/routes/settings.php'));

        if(config('cms-orbit.settings_demo')){
            Route::domain((string) config('platform.domain'))
                ->prefix(Dashboard::prefix('/'))
                ->middleware(config('platform.middleware.private'))
                ->name('settings.examples.')
                ->group(app_path('Settings/routes/examples.php'));
        }

        foreach(CmsHelper::getEntities() as $entity){
            $routeFile = $entity['directory'].'/routes/settings.php';
            if(file_exists($routeFile)){
                Route::domain((string) config('platform.domain'))
                    ->prefix(Dashboard::prefix('/'))
                    ->middleware(config('platform.middleware.private'))
                    ->name('settings.entities.')
                    ->group($routeFile);
            }
        }
    }

    private function setIntegrationKeys(): void
    {
        $integrationKeysGroup = SiteConfigHandler::registerConfigGroup('integrationKeys', 9000, [
            'icon' => 'bs.link',
            'title' => __('Integration Keys'),
            'description' => __('Manage API and Authentication Keys settings in a centralized way.')
        ]);
        SiteConfigHandler::registerConfigSection('integrationKeys', 'verification', [
            'title' => __('Analytics and Verification Keys'),
            'description' => __('Add and manage analytics and site ownership verification keys for your website.')
        ]);

        SiteConfigHandler::registerConfigItem('integrationKeys', 'google_analytics_id', 'text', '', 'verification', [
            'title' => __('Google Analytics ID'),
            'description' => __('Your Google Analytics tracking ID')
        ]);
        SiteConfigHandler::registerConfigItem('integrationKeys', 'naver_site_verification', 'text', '', 'verification', [
            'title' => __('Naver Site Verification'),
            'description' => __('Naver Search Console site verification code')
        ]);
        SiteConfigHandler::registerConfigItem('integrationKeys', 'google_site_verification', 'text', '', 'verification', [
            'title' => __('Google Site Verification'),
            'description' => __('Google Search Console site verification code')
        ]);
    }

    private function setThemeConfigs(): void
    {
        $themeGroup = SiteConfigHandler::registerConfigGroup('theme', 3000, [
            'icon' => 'bs.palette',
            'title' => __('Theme Settings'),
            'description' => __('Manage settings related to the website\'s theme.')
        ]);


        // 테마 색상 섹션
        SiteConfigHandler::registerConfigSection('theme', 'colors', [
            'title' => __('Theme Colors'),
            'description' => __('Configure primary and secondary colors for the website theme.')
        ]);

        SiteConfigHandler::registerConfigItem('theme', 'primary_color', 'color', '', 'colors', [
            'title' => __('Primary Color'),
            'description' => __('The main color used for the website theme')
        ]);

        SiteConfigHandler::registerConfigItem('theme', 'secondary_color', 'color', '', 'colors', [
            'title' => __('Secondary Color'),
            'description' => __('The secondary color used for the website theme')
        ]);

        // 테마 이미지 섹션
        SiteConfigHandler::registerConfigSection('theme', 'images', [
            'title' => __('Theme Images'),
            'description' => __('Upload images related to the website theme.')
        ]);

        SiteConfigHandler::registerConfigItem('theme', 'logo', 'image', '', 'images', [
            'title' => __('Website Logo'),
            'description' => __('The logo displayed on the website')
        ]);

        SiteConfigHandler::registerConfigItem('theme', 'favicon', 'image', '', 'images', [
            'title' => __('Favicon'),
            'description' => __('The small icon displayed in the browser tab')
        ]);

        SiteConfigHandler::registerConfigItem('theme', 'background_image', 'image', '', 'images', [
            'title' => __('Background Image'),
            'description' => __('The background image used on the website')
        ]);
    }


    private function setSEOConfigs(): void
    {
        $seoGroup = SiteConfigHandler::registerConfigGroup('seo', 1000, [
            'icon' => 'bs.search-heart',
            'title' => __('SEO Settings'),
            'description' => __('Manage settings related to Search Engine Optimization (SEO) for the website.')
        ]);

        // 기본 메타 태그 섹션
        SiteConfigHandler::registerConfigSection('seo', 'basic_meta', [
            'title' => __('Basic Meta Tags'),
            'description' => __('Configure basic meta tags for your website')
        ]);

        // 기본 메타 태그 설정
        SiteConfigHandler::registerConfigItem('seo', 'title', 'text', '', 'basic_meta', [
            'title' => __('Site Title'),
            'description' => __('The main title of your website that appears in search results')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'description', 'textarea', '', 'basic_meta', [
            'title' => __('Meta Description'),
            'description' => __('A brief description of your website for search engines')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'keywords', 'textarea', '', 'basic_meta', [
            'title' => __('Meta Keywords'),
            'description' => __('Keywords related to your website (comma separated)')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'author', 'text', '', 'basic_meta', [
            'title' => __('Author'),
            'description' => __('The author or organization name')
        ]);

        // Open Graph 섹션
        SiteConfigHandler::registerConfigSection('seo', 'open_graph', [
            'title' => __('Open Graph Settings'),
            'description' => __('Configure Open Graph meta tags for social media sharing')
        ]);

        SiteConfigHandler::registerConfigItem('seo', 'og_type', 'text', 'website', 'open_graph', [
            'title' => __('OG Type'),
            'description' => __('The type of your object (e.g., website, article)')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'og_site_name', 'text', '', 'open_graph', [
            'title' => __('OG Site Name'),
            'description' => __('The name of your website for social media')
        ]);

        // Twitter Card 섹션
        SiteConfigHandler::registerConfigSection('seo', 'twitter_card', [
            'title' => __('Twitter Card Settings'),
            'description' => __('Configure Twitter Card meta tags for Twitter sharing')
        ]);

        SiteConfigHandler::registerConfigItem('seo', 'twitter_card', 'text', 'summary', 'twitter_card', [
            'title' => __('Twitter Card Type'),
            'description' => __('The type of Twitter Card to use (e.g., summary, summary_large_image, app, or player)')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'twitter_creator', 'text', '', 'twitter_card', [
            'title' => __('Twitter Creator'),
            'description' => __('The content creator\'s Twitter username')
        ]);

        //이미지 관련 섹션
        SiteConfigHandler::registerConfigSection('seo', 'images', [
            'title' => __('Website Meta Information'),
            'description' => __('Set up fundamental meta tags to enhance your website\'s SEO.')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'app_icon', 'picture', '', 'images', [
            'title' => __('App Icon (512x512)'),
            'description' => __('Upload a 512x512 app icon for your site or application')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'thumbnail', 'picture', '', 'images', [
            'title' => __('Default Thumbnail'),
            'description' => __('The default image to show when sharing on social media')
        ]);

        // 고급 설정 섹션
        SiteConfigHandler::registerConfigSection('seo', 'advanced', [
            'title' => __('Advanced Settings'),
            'description' => __('Configure advanced SEO settings and verification codes')
        ]);

        SiteConfigHandler::registerConfigItem('seo', 'robots', 'text', 'index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1', 'advanced', [
            'title' => __('Robots Meta Tag'),
            'description' => __('Control how search engines should handle your website')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'enable_sitemap', 'boolean', true, 'advanced', [
            'title' => __('Enable Sitemap'),
            'description' => __('Automatically generate and update sitemap.xml')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'enable_robots_txt', 'boolean', true, 'advanced', [
            'title' => __('Enable robots.txt'),
            'description' => __('Use custom robots.txt configuration')
        ]);
        SiteConfigHandler::registerConfigItem('seo', 'custom_robots_txt', 'textarea', file_get_contents(public_path('default_robots.txt')), 'advanced', [
            'title' => __('Custom robots.txt'),
            'description' => __('Custom rules for robots.txt file')
        ]);
    }
}