slovocast/app/app/Controllers/Pages.php

27 lines
516 B
PHP

<?php
namespace App\Controllers;
use CodeIgniter\Exceptions\PageNotFoundException;
class Pages extends BaseController
{
public function index(): string
{
return $this->view();
}
public function view(string $page = "home"): string
{
if (!is_file(APPPATH . 'Views/pages/' . $page . '.php')) {
throw new PageNotFoundException($page);
}
$data = [
'title' => ucfirst($page)
];
return view('pages/' . $page, $data);
}
}