<?php

namespace App\Controllers\Admin;

use App\Models\SitepageModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;

class SitepageController extends AdminController
{
    public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        parent::initController($request, $response, $logger);
        $this->_model = new SitepageModel();
        $this->_viewDatas['className'] = 'Sitepage';
        $this->_viewPath .= strtolower($this->_viewDatas['className']);
        $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
        $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
        helper($this->_viewDatas['className']);
    }

    public function getFields(string $action = ""): array
    {
        $fields = ["category", 'title', "status", "content"];
        switch ($action) {
            case "index":
            case "excel":
                return ["category", "user_uid",  'title', "status", "created_at"];
                break;
            case "view":
                return ["category", "user_uid",  'title', "status", "created_at", "content"];
                break;
            default:
                return $fields;
                break;
        }
    }
    public function getFieldFilters(): array
    {
        return ["category", "user_uid", "status"];
    }
    public function getFieldBatchFilters(): array
    {
        return parent::getFieldBatchFilters();
    }
}
