<?php

namespace App\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;

abstract class BaseController extends Controller
{
    protected $session;
    protected array $helpers = ['url', 'form', 'text', 'tibaleta'];

    public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        parent::initController($request, $response, $logger);
        $this->session = service('session');
    }

    protected function render(string $view, array $data = [], string $layout = 'layouts/public')
    {
        $data['view'] = $view;
        $data['authUser'] = $this->session->get('auth_user');
        return view($layout, $data);
    }

    protected function portal(string $view, array $data = [], string $area = 'patient')
    {
        $data['view'] = $view;
        $data['area'] = $area;
        $data['authUser'] = $this->session->get('auth_user');
        return view('layouts/dashboard', $data);
    }
}
