<?php

namespace App\Controllers;

class Page extends BaseController
{
    public function index($slug)
    {
        $result = $this->db->table('page')->where('slug', $slug)->get();
        if ($result->getNumRows() === 0) {
            throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
        }

        $data = [
            'func'  => $this->func,
            'db'    => $this->db,
            'titel' => ucwords(strtolower($slug)),
            'rows'  => $result->getResult(),
        ];

        return view('customer/head', $data) . view('customer/main/page', $data) . view('customer/foot', $data);
    }
}
