<?php

namespace Entity\Model;

use Helpers\QueryBuilder\QueryBuilder;

class Hastutil extends QueryBuilder
{
    protected string $table = 'HASTUTIL with (nolock)';
    protected string $primaryKey = 'CODE';
    protected string $libelle = 'NOM';

    public function find($id, array $selectTables = [], $post = [], $option = null)
    {
        // Case : current user -> cache in Session (used in User::getHastutil())
        if ($id == ($_SESSION["Session_Login"] ?? null) && empty($selectTables) && empty($post)) {
            return $_SESSION['User']['Hastutil'] ?? (
                $_SESSION['User']['Hastutil'] = parent::find($id)
            );
        }
        return parent::find($id, $selectTables, $post, $option);
    }
}
