This package can help you in creating autonumbers for your laravel model. You can create autonumbers using the artisan command, and it will generate the autonumber whenever you create a record using your model.
You can install the package via composer:
composer require frikishaan/autonumber-laravelFirst you have to run migration. It will create a table in your database named autonumbers.
php artisan migrateThen use the below command to create autonumber -
php artisan autonumber:createUse the HasAutonumber trait in your model. It will generate the autonumber when you create a record using your model.
<?php
namespace App\Models;
use Frikishaan\Autonumber\Traits\HasAutonumber;
use Illuminate\Database\Eloquent\Model;
class Invoice extends Model
{
use HasAutonumber;
protected $fillable = [
'customer', 'amount',
];
}composer testThe MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.