<?php

namespace App\Controllers;

class Blog extends BaseController
{
    public function index()
    {
        $data = ['func' => $this->func, 'db' => $this->db];

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

    public function single($url = null)
    {
        $res = $this->db->table('blog')->where('url', $url)->get()->getRow();
        if ($res === null) {
            throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
        }

        $data = ['func' => $this->func, 'db' => $this->db, 'res' => $res, 'titel' => $res->judul];

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