<?php

namespace Entity\Model;

use Helpers\QueryBuilder\QueryBuilder;

class OxaEventDet extends QueryBuilder
{
    protected string $table = 'OXAEVENTDET with (nolock)';
    protected string $primaryKey = 'NUMTRT';

    
    /**
     * @param array<mixed> $entity
     * @return void
     */
    protected function setAutoincrementExpr(array &$entity) :void
    {
        if (empty($entity['NUMLIG'])) {
            $entity['NUMLIG'] = [
                'expr' =>
                    "SELECT COALESCE( MAX(NUMLIG) + 1, 1)
                    FROM OXAEVENTDET
                    WHERE NUMTRT = :numtrt",
                'param' => [
                    ':numtrt' => $entity['NUMTRT'],
                ],
            ];
        }
    }
}
