controller refactoring part 4

This commit is contained in:
Peter Papp
2021-07-20 10:27:00 +02:00
parent 2e52af5275
commit 8c493395c4
6 changed files with 112 additions and 71 deletions
@@ -37,35 +37,6 @@ class AppFunctionsController extends Controller
) {
}
/**
* Show index page
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
try {
// Try to connect to database
\DB::getPdo();
// Get setup status
$setup_status = get_setup_status();
// Get app pages
$pages = Page::all();
// Get all settings
$settings = get_settings_in_json();
} catch (PDOException $e) {
$setup_status = 'setup-database';
}
return view('index')
->with('settings', $settings ?? null)
->with('legal', $pages ?? null)
->with('installation', $setup_status);
}
/**
* Get og site for web crawlers
*
@@ -102,23 +73,6 @@ class AppFunctionsController extends Controller
]);
}
/**
* Send contact message from pages
*
* @param SendContactMessageRequest $request
* @return ResponseFactory|Response
*/
public function contact_form(SendContactMessageRequest $request)
{
Mail::to(
get_setting('contact_email')
)->send(
new SendContactMessage($request->all())
);
return response('Done', 201);
}
/**
* Get single page content
*
@@ -179,25 +133,4 @@ class AppFunctionsController extends Controller
->values()
->all();
}
/**
* Get language translations for frontend app
*/
public function get_translations($lang)
{
$translations = cache()
->rememberForever("language-translations-$lang", function () use ($lang) {
try {
return Language::whereLocale($lang)
->firstOrFail()
->languageTranslations;
} catch (QueryException | ModelNotFoundException $e) {
return null;
}
});
return $translations
? map_language_translations($translations)
: get_default_language_translations();
}
}