<?php

use App\Http\Controllers\Admin;
use App\Http\Controllers\Admin\Auth;
use App\Http\Controllers\Admin\Contest;
use App\Http\Controllers\Admin\Extra;
use App\Http\Controllers\Admin\Notification\NotificationController;
use App\Http\Controllers\Admin\Quiz;
use App\Http\Controllers\Admin\Quiz\LevelController;
use App\Http\Controllers\Admin\Settings\CustomCssController;
use App\Http\Controllers\Admin\Settings\ServiceController;
use App\Http\Controllers\Admin\User;
use App\Http\Middleware\AdminAuthMiddleware;
use App\Http\Middleware\AdminGuestMiddleware;
use App\Http\Middleware\DemoMiddleware;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Route;

/**
 * redirect to admin dashboard it the user hit the base url
 */
Route::middleware(AdminGuestMiddleware::class)->group(function () {
    Route::get('login', [Auth\AuthenticatedSessionController::class, 'create'])
        ->name('login');

    Route::post('login', [Auth\AuthenticatedSessionController::class, 'store']);

    Route::get('forgot-password', [Auth\PasswordResetLinkController::class, 'create'])
        ->name('password.request');

    Route::post('forgot-password', [Auth\PasswordResetLinkController::class, 'store'])
        ->name('password.email');

    Route::get('reset-password/{token}', [Auth\NewPasswordController::class, 'create'])
        ->name('password.reset');

    Route::post('reset-password', [Auth\NewPasswordController::class, 'store'])
        ->name('password.store');
});

Route::middleware([AdminAuthMiddleware::class])->group(function () {
    /**
     * auth routes
     */
    Route::post('logout', [Auth\AuthenticatedSessionController::class, 'destroy'])
        ->name('logout');
    Route::get('change-language/{code}', [Admin\Settings\Language\LanguageController::class, 'changeLang'])->name('change-language');
    /**---------------------- dashboard ---------------------- */

    Route::get('/dashboard', [Admin\DashboardController::class, 'index'])->name('dashboard');
    Route::group(['prefix' => 'dashboard/overview', 'as' => 'dashboard.overview.'], function () {
        Route::get('transactions', [Admin\DashboardController::class, 'transactionOverview'])->name('transaction');
        Route::get('withdrawals', [Admin\DashboardController::class, 'withdrawalOverview'])->name('withdrawals');
        Route::get('deposits', [Admin\DashboardController::class, 'depositOverview'])->name('deposits');
        Route::get('contest_participants', [Admin\DashboardController::class, 'contestParticipantOverview']);
        Route::get('quiz_participants', [Admin\DashboardController::class, 'quizParticipantOverview']);
        Route::get('commissions', [Admin\DashboardController::class, 'commissionOverview'])->name('commissions');
        Route::get('login_log', [Admin\DashboardController::class, 'loginLogOverview'])->name('login_log');
        Route::get('login_log_browser', [Admin\DashboardController::class, 'loginLogBrowserOverview'])->name('login_log_browser');
        Route::get('login_log_by_day', [Admin\DashboardController::class, 'loginLogOverviewBYDay'])->name('login_log_by_day');
    });
    /** ---------------------- end dashboard ---------------------- */
    Route::group(['middleware' => [DemoMiddleware::class]], function () {
        /**---------------------- notifications ---------------------- */
        Route::resource('notifications', NotificationController::class)->except('create', 'edit', 'update');
        Route::get('get-latest-notification', [NotificationController::class, 'getLatestNotification'])->name('get-latest-notification');
        Route::get('delete-all-notification', [NotificationController::class, 'deleteAllNotification'])->name('delete-all-notification');
        Route::get('read-all-notification', [NotificationController::class, 'readAllNotification'])->name('read-all-notification');
        /** ---------------------- end notifications ---------------------- */

        /** -------------------------- QUIZ -------------------------- */
        Route::group(['prefix' => 'quizzes'], function () {
            Route::resource('quiz-categories', Quiz\CategoryController::class)->except('show');
            Route::resource('levels', LevelController::class)->except(['show', 'create', 'edit']);
        });
        Route::get('quiz-category-list', [Quiz\QuizHelperController::class, 'getCategories'])->name('quiz.category.list');
        Route::resource('quizzes', Quiz\QuizController::class);
        Route::get('change-status/{quiz}', [Quiz\QuizHelperController::class, 'changeStatus'])->name('quizzes.change-status');
        Route::post('quiz-bulk-import/{quiz}', [Quiz\QuestionController::class, 'bulkImport'])->name('quiz.bulk-import');

        Route::resource('quizzes.question-levels', Quiz\QuestionLevelController::class)->except(['show', 'create', 'create']);
        Route::resource('quizzes.questions', Quiz\QuestionController::class)->except('show');
        Route::get('quizzes/questions/{quiz}/generate', [Quiz\AiQuestionController::class, 'createWithAi'])->name('quizzes.questions.create.ai');
        Route::get('quizzes/questions/{quiz}/edit', [Quiz\AiQuestionController::class, 'editWithAi'])->name('quizzes.questions.edit.ai');
        Route::post('quizzes/questions/{quiz}/store', [Quiz\AiQuestionController::class, 'generateQuestionByAi'])->name('quizzes.questions.store.ai');
        Route::put('quiz/questions/{quiz}/update-order', [Quiz\QuestionController::class, 'updateOrder'])->name('quiz.questions.update-order');
        /** -------------------------- END QUIZ -------------------------- */

        /** -------------------------- CONTEST -------------------------- */
        Route::group(['prefix' => 'contests'], function () {
            Route::resource('winners', Contest\WinnerController::class);
            Route::resource('contest-categories', Contest\CategoryController::class)->except('show', 'edit', 'create');
        });
        Route::resource('contests', Contest\ContestController::class);
        Route::post('contest-bulk-import/{contest}', [Contest\QuestionController::class, 'bulkImport'])->name('contest.bulk-import');
        Route::get('publish/{contest}', [Contest\ContestHelperController::class, 'publish'])->name('contests.publish');
        Route::get('unpublish/{contest}', [Contest\ContestHelperController::class, 'unPublish'])->name('contests.unpublish');
        Route::get('contest-category-list', [Contest\ContestHelperController::class, 'getCategories'])->name('contest.category.list');
        Route::resource('contests.questions', Contest\QuestionController::class)->except('show');
        Route::get('contests/questions/{contest}/generate', [Contest\AiQuestionController::class, 'createWithAi'])->name('contests.questions.create.ai');
        Route::get('contests/questions/{contest}/edit', [Contest\AiQuestionController::class, 'editWithAi'])->name('contests.questions.edit.ai');
        Route::post('contests/questions/{contest}/store', [Contest\AiQuestionController::class, 'generateQuestionByAi'])->name('contests.questions.store.ai');
        Route::put('contest/questions/{contest}/update-order', [Contest\QuestionController::class, 'updateOrder'])->name('contests.questions.update-order');
        Route::resource('contests.prizes', Contest\PrizeController::class)->except(['show', 'edit', 'create']);
        Route::put('contest/prizes/{contest}/update-rank', [Contest\QuestionController::class, 'updateOrder'])->name('contests.prizes.update-rank');
        /** -------------------------- END CONTEST -------------------------- */

        /** -------------------------- BADGE -------------------------- */
        Route::resource('badges', Admin\Badge\BadgeController::class);
        Route::get('badge-users/{badge}', [Admin\Badge\BadgeController::class, 'badgeUsers'])->name('badge-users');
        /** -------------------------- END BADGE -------------------------- */

        /** -------------------------- CONTACT -------------------------- */
        Route::resource('contacts', Admin\Contact\ContactController::class);
        Route::get('delete-all', [Admin\Contact\ContactController::class, 'deleteAll'])->name('contact-delete-all');
        /** -------------------------- END CONTACT -------------------------- */

        /** -------------------------- SUBSCRIPTIONS -------------------------- */
        Route::resource('subscriptions', Admin\SubscriptionController::class)->only(['index', 'create', 'store', 'destroy']);
        /** -------------------------- END SUBSCRIPTIONS -------------------------- */

        /**
         * withdraw method and withdrawal
         */
        Route::resource('withdrawals', Admin\Withdraw\WithdrawalController::class)->only(['index', 'show', 'update']);

        /**
         * deposit method and deposits
         */
        Route::resource('deposits', Admin\Deposit\DepositController::class)->only(['index', 'show', 'update']);

        /** -------------------------- Users -------------------------- */
        Route::group(['prefix' => 'users', 'as' => 'users.'], function () {
            Route::post('add-balance/{user}', [User\UserController::class, 'addBalance'])->name('add-balance');
            Route::post('subtract-balance/{user}', [User\UserController::class, 'subtractBalance'])->name('subtract-balance');
            Route::post('deactivate/{user}', [User\UserController::class, 'deactivate'])->name('deactivate');
            Route::resource('notifications', User\NotificationController::class)->only(['index', 'store']);
            Route::get('ban/{user}', [User\UserController::class, 'banAccount'])->name('ban');
            Route::get('signin/{user}', [User\UserController::class, 'signInUser'])->name('signin');
            Route::get('kyc/{user}', [User\UserController::class, 'kycForms'])->name('kyc-verify');
            Route::get('kyc-verify-accept/{user}', [User\UserController::class, 'kycVerifyAccept'])->name('kyc.verify.accept');
            Route::get('kyc-verify-reject/{user}', [User\UserController::class, 'kycVerifyReject'])->name('kyc.verify.reject');
        });
        Route::resource('users', User\UserController::class)->only(['index', 'edit', 'update', 'destroy']);
        /** -------------------------- End User USER -------------------------- */

        /** -------------------------- ADMIN USER -------------------------- */
        Route::resource('admin-roles', Admin\AdminUser\RoleController::class);
        Route::resource('admins', Admin\AdminUser\UserController::class);
        Route::group(['prefix' => 'profile', 'as' => 'profile.', 'controller' => Admin\Settings\AdminProfileController::class], function () {
            Route::get('/', 'index')->name('index');
            Route::post('/', 'update')->name('update');
            Route::post('change-password', [Admin\Settings\AdminProfileController::class, 'changePassword'])->name('change-password');
        });
        /** -------------------------- END ADMIN USER -------------------------- */

        /** -------------------------- SUPPORT TICKET -------------------------- */
        Route::get('support-tickets/users', [Admin\SupportTicket\SupportTicketController::class, 'users'])->name('support-tickets.users');
        Route::post('support-tickets/ticket-store', [Admin\SupportTicket\SupportTicketController::class, 'storeTicket'])->name('support-tickets.ticket-store');
        Route::get('support-tickets-chats', [Admin\SupportTicket\SupportTicketController::class, 'supportTickets'])->name('support-tickets.chats');
        Route::resource('support-tickets', Admin\SupportTicket\SupportTicketController::class)->except(['create', 'edit', 'update']);
        /** -------------------------- END SUPPORT TICKET -------------------------- */

        /** -------------------------- REPORTS -------------------------- */
        Route::group(['prefix' => 'reports', 'as' => 'reports.'], function () {
            Route::get('/quizzes', [Admin\Report\QuizReportController::class, 'index'])->name('quizzes');
            Route::get('/quizzes/export/{type}', [Admin\Report\QuizReportController::class, 'getExport'])->name('quizzes.export');

            Route::get('/contests', [Admin\Report\ContestReportController::class, 'index'])->name('contests');
            Route::get('/contests/export/{type}', [Admin\Report\ContestReportController::class, 'getExport'])->name('contests.export');

            Route::get('/contest-participants', [Admin\Report\ContestParticipantReportController::class, 'index'])->name('contest-participants');
            Route::get('/contest-participants/export/{type}', [Admin\Report\ContestParticipantReportController::class, 'getExport'])->name('contest-participants.export');

            Route::get('/transactions', [Admin\Report\TransactionController::class, 'index'])->name('transactions');
            Route::get('/transactions/export/{type}', [Admin\Report\TransactionController::class, 'getExport'])->name('transactions.export');

            Route::get('/login_log', [Admin\Report\LoginLogController::class, 'index'])->name('login_log');
            Route::get('/login_log/export/{type}', [Admin\Report\LoginLogController::class, 'getExport'])->name('login_log.export');

            Route::get('/buy-coins', [Admin\Report\BuyCoinController::class, 'index'])->name('buy_coins');
            Route::get('/buy-coins/export/{type}', [Admin\Report\BuyCoinController::class, 'getExport'])->name('buy_coins.export');

            Route::get('/withdrawals', [Admin\Report\WithdrawController::class, 'index'])->name('withdrawals');
            Route::get('/withdrawals/export/{type}', [Admin\Report\WithdrawController::class, 'getExport'])->name('withdrawals.export');
        });
        /** -------------------------- END REPORTS -------------------------- */

        /** -------------------------- PAYMENTS -------------------------- */
        Route::group(['prefix' => 'payments', 'as' => 'payments.', 'controller' => Admin\PaymentController::class], function () {
            Route::get('/', 'index')->name('index');
            Route::get('/{payment}', 'show')->name('show');
            Route::post('/cancel/{payment}', 'cancel')->name('cancel');
            Route::post('/accept/{payment}', 'accept')->name('accept');
        });

        /** -------------------------- SETTINGS -------------------------- */
        Route::group(['prefix' => 'settings', 'as' => 'settings.'], function () {
            Route::get('/', Admin\Settings\SettingController::class)->name('index');

            Route::prefix('system')->group(function () {
                /** -------------------------- APP -------------------------- */
                Route::group(['prefix' => 'app', 'as' => 'app.', 'controller' => Admin\Settings\AppController::class], function () {
                    Route::get('/', 'index')->name('index');
                    Route::post('/info', 'infoUpdate')->name('info.update');
                    Route::post('/otp', 'otpUpdate')->name('otp.update');
                });
                /** -------------------------- END APP -------------------------- */

                /** -------------------------- SYSTEM CONFIGURATION -------------------------- */
                Route::group(['prefix' => 'system-configurations', 'as' => 'system-configurations.', 'controller' => Admin\Settings\SystemConfigurationController::class], function () {
                    Route::get('pagination', 'pagination')->name('pagination.index');
                    Route::post('pagination', 'storePagination')->name('pagination.store');
                });
                Route::resource('system-configurations', Admin\Settings\SystemConfigurationController::class)->only(['index', 'store']);
                /** -------------------------- END SYSTEM CONFIGURATION -------------------------- */

                /** -------------------------- SCHEDULER -------------------------- */
                Route::resource('task-schedules', Admin\Settings\Schedule\TaskScheduleController::class)->except('create', 'edit');
                Route::controller(Admin\Settings\Schedule\TaskScheduleController::class)->group(function () {
                    Route::get('/task-schedule-status-change/{taskSchedule}', 'statusUpdate')->name('task-schedules.status-change');
                    Route::get('/run-now/{taskSchedule}', 'runNow')->name('task-schedules.run');
                    Route::get('/task-schedule/logs/{taskSchedule}', 'getLogs')->name('task-schedules.logs');
                    Route::get('/task-schedule/remove-logs/{taskSchedule}', 'removeLogs')->name('task-schedules.remove-logs');
                });
                Route::resource('schedule-times', Admin\Settings\Schedule\CronTimeController::class)->except('create', 'edit');
                /** -------------------------- END SCHEDULER -------------------------- */

                /** -------------------------- MAINTENANCE MODE SETTINGS -------------------------- */
                Route::resource('maintenance', Admin\Settings\MaintenanceController::class)->only(['index', 'store']);
                /** -------------------------- END MAINTENANCE MODE SETTINGS -------------------------- */

                /** -------------------------- COOKIES POLICY -------------------------- */
                Route::resource('gdpr-cookies', Admin\Settings\CookieController::class)->only(['index', 'store']);
                /** -------------------------- END COOKIES POLICY -------------------------- */
            });

            Route::prefix('finance')->group(function () {
                /** -------------------------- CURRENCIES -------------------------- */
                Route::group(['prefix' => 'currencies', 'as' => 'currencies.'], function () {
                    Route::get('/refresh', [Admin\Settings\CurrencyController::class, 'refresh'])->name('refresh');
                    Route::get('/change-default/{currency}', [Admin\Settings\CurrencyController::class, 'changeDefault'])->name('change-default');
                });
                Route::resource('currencies', Admin\Settings\CurrencyController::class)->except(['show', 'create']);
                /** -------------------------- END CURRENCIES -------------------------- */
                /** -------------------------- PAYMENT METHOD -------------------------- */
                Route::resource('payment-methods', Admin\Settings\Payment\PaymentMethodController::class)->except('show');
                Route::get('change-status/{paymentMethod}', [Admin\Settings\Payment\PaymentMethodController::class, 'changeStatus'])->name('payment-methods.change-status');
                /** -------------------------- END PAYMENT METHOD -------------------------- */

                /** -------------------------- WITHDRAW METHOD -------------------------- */
                Route::resource('withdraw-methods', Admin\Settings\WithdrawMethodController::class);
                /** -------------------------- END WITHDRAW METHOD -------------------------- */
            });

            Route::prefix('user')->group(function () {
                /** -------------------------- NOTIFICATION SETTINGS -------------------------- */
                Route::group(['prefix' => 'notification', 'as' => 'notification.'], function () {
                    Route::resource('templates', Admin\Settings\Notification\NotificationTemplateController::class)->except(['index', 'show']);
                    Route::group(['controller' => Admin\Settings\Notification\ServicesController::class], function () {
                        Route::get('services', 'index')->name('services');
                        Route::post('services/{service}', 'store')->name('services.store');
                        Route::post('test/email', 'testEmailService')->name('test.email');
                        Route::get('preview/email/{templateBody}', 'previewEmail')->name('preview.email');
                        Route::post('test/sms', 'testSmsService')->name('test.sms');

                        // upload firebase json config file
                        Route::post('firebase/json/{type}', 'uploadFirebaseJson')->name('firebase.json');

                        Route::get('firebase/json/download/{type}', 'downloadFirebaseJson')->name('firebase.json.download');
                        Route::post('test/firebase', 'testFirebaseService')->name('test.firebase');
                        /**
                         * firebase notification fcm token update route
                         */
                        Route::post('token-update', 'tokenUpdate')->name('token.update');
                    });
                });
                Route::get('change-status/{notificationTemplate}', [Admin\Settings\Notification\NotificationTemplateController::class, 'changeStatus'])->name('notification-templates.change-status');
                /** -------------------------- END NOTIFICATION TEMPLATE -------------------------- */

                /** -------------------------- SOCIALITES -------------------------- */
                Route::resource('socialites', Admin\Settings\SocialiteController::class)->only(['index', 'update']);
                Route::get('socialite/{socialite}/enable', [Admin\Settings\SocialiteController::class, 'enable'])->name('socialites.enable');
                /** -------------------------- END SOCIALITES -------------------------- */

                /** -------------------------- KYC FORM -------------------------- */
                Route::resource('kyc-forms', Admin\Settings\KycFormController::class)->except(['create', 'show']);
                Route::post('kyc-form-position-update', [Admin\Settings\KycFormController::class, 'updatePosition'])->name('kyc-forms.position-update');
                /** -------------------------- END KYC FORM -------------------------- */
            });

            Route::prefix('theme')->group(function () {
                /** -------------------------- FRONTEND CONTENT -------------------------- */
                Route::resource('frontend-sections', Admin\Settings\FrontendSection\FrontendSectionController::class)->except(['show', 'destroy']);
                Route::resource('teams', Admin\Settings\TeamController::class)->except(['show']);
                Route::resource('testimonials', Admin\Settings\TestimonialController::class)->except(['create', 'show', 'edit']);
                Route::resource('faqs', Admin\Settings\FaqController::class)->except(['create', 'show', 'edit']);
                /** -------------------------- END FRONTEND CONTENT -------------------------- */

                /** -------------------------- PAGES -------------------------- */
                Route::resource('pages', Admin\Settings\Pages\PageController::class);
                Route::get('pages/{page}/change-status', [Admin\Settings\Pages\PageController::class, 'changeStatus'])->name('page.change-status');
                Route::post('pages/{page}/update-section', [Admin\Settings\Pages\PageController::class, 'updateSection'])->name('page.update-section');
                Route::put('pages/{page}/update-without-section-content', [Admin\Settings\Pages\PageController::class, 'updateWithoutSectionContent'])->name('page.update-without-section-content');
                Route::resource('/pages/{page}/seo', Admin\Settings\Pages\SeoController::class)->only(['index', 'store'])->names('pages.seo');
                /** -------------------------- END PAGES -------------------------- */

                /** -------------------------- CUSTOM CSS -------------------------- */
                Route::resource('custom-css', CustomCssController::class)->only(['index', 'store']);

                /** -------------------------- PWA CONFIG -------------------------- */
                Route::resource('pwa', Admin\Settings\PwaConfigController::class);

                /** -------------------------- LOGO & FAVICON -------------------------- */
                Route::resource('logo-favicon', Admin\Settings\LogoFaviconController::class)->only(['index', 'store']);
            });

            Route::prefix('quiz')->group(function () {
                /** -------------------------- Coin SETTINGS -------------------------- */
                Route::resource('coin-settings', Admin\Settings\Quiz\CoinSettingController::class)->only(['index', 'store']);
                /** -------------------------- END Coin SETTINGS -------------------------- */

                /** -------------------------- Quiz RANKING SETTINGS -------------------------- */
                Route::resource('quiz-ranking-settings', Admin\Settings\Quiz\UserLevelSettingController::class)->only(['index', 'store', 'update', 'destroy']);
                /** -------------------------- Quiz RANKING SETTINGS -------------------------- */
            });

            Route::prefix('integration')->group(function () {
                /** -------------------------- CUSTOM CSS -------------------------- */
                Route::resource('services', ServiceController::class)->only(['index', 'store']);

                /** -------------------------- AI SETTINGS -------------------------- */
                Route::resource('ai-settings', Admin\Settings\AIController::class)->only(['index', 'update']);
                Route::get('ai-settings/{ai}/enable', [Admin\Settings\AIController::class, 'enable'])->name('ai-settings.enable');
                Route::get('ai-settings/logs', [Admin\Settings\AIController::class, 'logs'])->name('ai-settings.logs');
                /** -------------------------- END AI SETTINGS -------------------------- */
                
                /** -------------------------- EXTENSION -------------------------- */
                Route::controller(Admin\Settings\ExtensionController::class)->group(function () {
                    Route::get('extensions', 'index')->name('extensions.index');
                    Route::put('extensions/{slug}', 'update')->name('extensions.update');
                    Route::get('extensions/{slug}/enable', 'enable')->name('extensions.enable');
                });
                /** -------------------------- END EXTENSION -------------------------- */

                /** -------------------------- Ads -------------------------- */
                Route::resource('ads', Admin\Advertisement\AdController::class)->except('show');
                Route::get('ads/{ad}/toggle-status', [Admin\Advertisement\AdController::class, 'toggleStatus'])->name('ads.toggle-status');
                /** -------------------------- End Ads -------------------------- */
            });

            Route::prefix('localization')->group(function () {
                /** -------------------------- LANGUAGES -------------------------- */
                Route::group(['prefix' => 'languages', 'as' => 'languages.'], function () {
                    Route::get('/download-help-json', [Admin\Settings\Language\LanguageController::class, 'downloadHelpJson'])->name('download-help-json');
                    Route::controller(Admin\Settings\Language\LanguageJsonController::class)->group(function () {
                        Route::get('/json/edit/{language}', 'index')->name('json.edit');
                        Route::post('/json/store/{language}', 'store')->name('json.store');
                        Route::put('/json/update/{language}', 'update')->name('json.update');
                        Route::delete('/json/destroy/{language}', 'destroy')->name('json.destroy');
                    });
                });
                Route::resource('languages', Admin\Settings\Language\LanguageController::class)->except('create');
                /** -------------------------- END LANGUAGES -------------------------- */

                /** -------------------------- SOCIAL_MEDIA -------------------------- */
                Route::resource('social-medias', Admin\Settings\SocialMediaController::class)->except(['create', 'show', 'edit']);
                /** -------------------------- END SOCIAL_MEDIA -------------------------- */
            });

            Route::prefix('navigation')->group(function () {
                /** -------------------------- MENU -------------------------- */
                Route::resource('menus', Admin\Settings\Menu\MenuController::class)->except(['create', 'show']);
                Route::get('menus/{menu}/change-status', [Admin\Settings\Menu\MenuController::class, 'changeStatus'])->name('menus.change-status');
                Route::group(['prefix' => 'menus', 'as' => 'menus.', 'controller' => Admin\Settings\Menu\MenuItemController::class], function () {
                    Route::post('/{menu}/item/store', 'store')->name('single.item.store');
                    Route::post('/{menu}/item/delete', 'destroy')->name('single.item.destroy');
                    Route::post('/{menu}/item/update', 'update')->name('single.item.update');
                    Route::post('/{menu}/item/bulk-update', 'bulkMenuItemUpdate')->name('bulk.item.update');
                });
                /** -------------------------- END MENU -------------------------- */
            });

            /** -------------------------- SEO -------------------------- */
            Route::prefix('seo')->name('seo.')->controller(Admin\Settings\SeoConfigController::class)->group(function () {
                Route::get('/', 'index')->name('index.page');
                Route::post('/', 'update')->name('update');
                Route::get('/sitemap', 'sitemap')->name('sitemap');
                Route::post('/sitemap', 'sitemapUpdate')->name('sitemap.update');
                Route::get('/generate-sitemap', 'generateSitemap')->name('generate.sitemap');
                Route::get('/robots', 'robots')->name('robots');
                Route::post('/robots', 'robotsUpdate')->name('robots.update');
                Route::get('/generate-robots', 'generateRobots')->name('generate.robots');
            });
            /** -------------------------- END SEO -------------------------- */

            /** -------------------------- ADMIN USER -------------------------- */
            Route::controller(Admin\Settings\AdminProfileController::class)->group(function () {
                Route::get('/profile', 'index')->name('profile');
                Route::post('/profile', 'update')->name('profile.update');
                Route::post('/profile/change-password', 'changePassword')->name('profile.change-password');
            });
        });
        /** -------------------------- END SETTINGS -------------------------- */
    });

    /** -------------------------- EXTRAS -------------------------- */
    Route::group(['prefix' => 'extras', 'as' => 'extras.'], function () {
        Route::get('application-info', [Extra\ApplicationInfoController::class, 'index'])->name('application-info');
        Route::get('cache/{command}', [Extra\CacheController::class, 'cacheClear'])->name('cache');
        Route::get('clear-frontend-cache', [Extra\CacheController::class, 'clearFrontendCache'])->name('clear-frontend-cache');
        Route::get('clear-cache', [Extra\CacheController::class, 'clearAll'])->name('clear-all');

        // application update routes
        Route::get('update', [Extra\ApplicationUpdateController::class, 'index'])->name('application-update');
        Route::post('check-for-update', [Extra\ApplicationUpdateController::class, 'store'])->name('check-for-update');
    });
    /** -------------------------- END EXTRAS -------------------------- */

    /** -------------------------- GAMES -------------------------- */
    Route::group(['prefix' => 'games', 'as' => 'games.'], function () {
        Route::resource('wordling', Admin\Game\WordlingWordController::class);
        Route::get('wordling/change-status/{game}', [Admin\Game\WordlingWordController::class, 'changeWordlingGameStatus'])->name('wordling.change-status');

        // hexling games
        Route::resource('hexling', Admin\Game\HexlingWordController::class);
        Route::get('hexling/change-status/{game}', [Admin\Game\HexlingWordController::class, 'changeHexlingGameStatus'])->name('hexling.change-status');
        Route::post('hexling/calculate-badge-stats', [Admin\Game\HexlingWordController::class, 'calculateBadgeStats'])->name('hexling.calculate-badge-stats');

        // hexling badges
        Route::resource('badges', Admin\Game\HexlingBadgeController::class);
        Route::post('badges/reorder', [Admin\Game\HexlingBadgeController::class, 'reorder'])->name('badges.reorder');
    });
});

/* -------------------------- FILEMANAGER -------------------------- */
Route::group(['prefix' => 'filemaneger', 'as' => 'filemaneger.', 'middleware' => ['auth:admin']], function () {
    try {
        \UniSharp\LaravelFilemanager\Lfm::routes();
    } catch (\Throwable $th) {
        // throw $th;
    }
});
/* -------------------------- END FILEMANAGER -------------------------- */

/* -------------------------- Helper STORAGE LINK Route-------------------------- */
Route::get('storage-link', function () {
    Artisan::call('storage:link');

    return response()->json(['message' => __('Storage linked successfully')]);
});
