PHP code example of tfsthiagobr98 / laravel-naming-series

1. Go to this page and download the library: Download tfsthiagobr98/laravel-naming-series library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tfsthiagobr98 / laravel-naming-series example snippets


return [
    'database' => [
        'connection' => null,
        'table' => 'naming_series',
    ],
    'split_with' => '.',
    'initial_increment' => 1000,
];

use TFSThiagoBR98\LaravelNamingSeries\Contracts\HasNamingSeries;
use TFSThiagoBR98\LaravelNamingSeries\Concerns\UsingNamingSeries;

class Contract extends Model implements HasNamingSeries
{
    use UsingNamingSeries;

    /**
     * Indicates if the model uses unique ids.
     *
     * @var bool
     */
    public $usesUniqueIds = true;

    /**
     * Field => Format list for model fields
     *
     * @var array<string,string>
     */
    public static function getSerieList(): array
    {
        return [
            'code' => 'CNT-.YY.MM.####',
        ];
    }

    /**
     * Get the columns that should receive a unique identifier.
     *
     * @return array
     */
    public function uniqueIds()
    {
        return [
            'code' => 'getSeriesField', // your series field
        ];
    }
bash
php artisan vendor:publish --tag="laravel-naming-series-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-naming-series-config"