$files ]); } public function getThemeTemplate() { $path = public_path('theme/'); $files = array_map(function ($item) use ($path) { return str_replace($path, '', $item); }, glob($path . '*')); return response([ 'data' => $files ]); } public function testSendMail(Request $request) { $obj = new SendEmailJob([ 'email' => $request->user['email'], 'subject' => 'This is v2board test email', 'template_name' => 'notify', 'template_value' => [ 'name' => config('v2board.app_name', 'V2Board'), 'content' => 'This is v2board test email', 'url' => config('v2board.app_url') ] ]); return response([ 'data' => true, 'log' => $obj->handle() ]); } public function setTelegramWebhook(Request $request) { $hookUrl = url('/api/v1/guest/telegram/webhook?access_token=' . md5(config('v2board.telegram_bot_token', $request->input('telegram_bot_token')))); $telegramService = new TelegramService($request->input('telegram_bot_token')); $telegramService->getMe(); $telegramService->setWebhook($hookUrl); return response([ 'data' => true ]); } public function fetch(Request $request) { $key = $request->input('key'); $data = (new ConfigService)->getDefaultConfig(); if ($key && isset($data[$key])) { return response([ 'data' => [ $key => $data[$key] ] ]); }; // TODO: default should be in Dict return response([ 'data' => $data ]); } public function save(ConfigSave $request) { $data = $request->validated(); $config = config('v2board'); foreach (ConfigSave::RULES as $k => $v) { if (!in_array($k, array_keys(ConfigSave::RULES))) { unset($config[$k]); continue; } if (array_key_exists($k, $data)) { $config[$k] = $data[$k]; } } $data = var_export($config, 1); if (!File::put(base_path() . '/config/v2board.php', " true ]); } }