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

View File

@@ -0,0 +1,39 @@
<?php
namespace Domain\Homepage\Controllers;
use Doctrine\DBAL\Driver\PDOException;
use Domain\Pages\Models\Page;
use Illuminate\View\View;
class IndexController
{
/**
* Show index page
*/
public function __invoke(): View
{
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);
}
}