vaened/php-sequence-generator

Facilitates the generation and autocompletion of a sequential value in the database

v2.0 2024-09-14 21:42 UTC

This package is auto-updated.

Last update: 2024-11-14 22:00:39 UTC


README

Facilitates the generation and autocompletion of a sequential value in the database

// Initialize Repository
$defaultRepository = new MysqlRepository(table: 'sequences');
$anotherRepository = new MysqlRepository(table: 'secuencias');

$normalizer = new Normalizer($defaultRepository);
$generator  = new Generator();
$resolver   = new SequentialIncrementer($normalizer, $generator);

// Define Series
$series = [
    Serie::for('number')->alias('invoice'),

    new Collection($anotherRepository, [
        Serie::for('serie_number')->styles([
            new FixedLength(8),
            new Prefixed('B')
        ]),
    ]),
];

// Make increments
$resolver->resolve('payments', $series);