<?php

namespace App\Controllers\Panel\Utils;

use App\Controllers\Panel\BC;
use CodeIgniter\API\ResponseTrait;

class Header extends BC
{
    use ResponseTrait;
    public function index()
    {
        if (!$this->request->isAJAX() && ENVIRONMENT != 'development') {
            exit('No direct script access allowed');
        }
        $user = user();
        $data['name'] = $user->fullname ?? 'Guest';
        try {
            $data['appname'] = options('appname') ?? "APP NAME";
            $data['logo'] = logo();
        } catch (\Throwable $th) {
            $data['appname'] = "APP NAME";
            $data['logo'] = logo();
        }
        $data['timezone'] = date_default_timezone_get();
        return $this->respond($data);
    }
}
