vaened/php-sequence-generator

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

v1.0.0 2022-12-19 14:47 UTC

This package is auto-updated.

Last update: 2024-04-19 17:35:54 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);