PHP code example of madebyclowd / laravel-auto-sequence

1. Go to this page and download the library: Download madebyclowd/laravel-auto-sequence 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/ */

    

madebyclowd / laravel-auto-sequence example snippets


$table->string('number')->nullable();

use MadeByClowd\AutoSequence\Contracts\Sequenceable;
use MadeByClowd\AutoSequence\Traits\HasSequenceNumber;
use Illuminate\Database\Eloquent\Model;

class Invoice extends Model implements Sequenceable
{
    use HasSequenceNumber;
}

class Invoice extends Model implements Sequenceable
{
    use HasSequenceNumber;

    public function getSequenceConfig(): array
    {
        return [
            'number' => [
                'module' => 'invoice',
                'type_code' => 'INV',
                'period' => 'monthly',
                'format_template' => '{type_code}-{YYYY}-{MM}-{seq:5}',
            ],
        ];
    }
}

$invoice = Invoice::create([...]); // don't set 'number' yourself, it fills in on its own
echo $invoice->number; // "INV-2026-06-00001"
bash
php artisan sequence:install
bash
php artisan migrate