PHP code example of marjose123 / laravel-numberizer
1. Go to this page and download the library: Download marjose123/laravel-numberizer 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/ */
marjose123 / laravel-numberizer example snippets
return [
/*
* '?' will be replaced with the increment number.
*/
'placeholder' => '?',
/*
* The number of digits in the autonumber
*/
'length' => (int) 6,
/*
* The Starting Value you want to start the creation of the incremental number
*/
'startingValue' => (int) 11111
];
use \MarJose123\LaravelNumberizer\Contracts\AutoNumber;
use \MarJose123\LaravelNumberizer\Concerns\HasNumberizer;
class Purchase extends Model implements AutoNumber
{
use HasNumberizer;
/**
* Return the autonumber configuration array for this model.
*
* @return array
*/
public function getAutoNumberOptions()
{
return [
'purchase_number' => [
'format' => 'PO-?', // autonumber format. '?' will be replaced with the generated number.
'length' => 5 // The number of digits in an autonumber
]
];
}
}
public function getAutoNumberOptions()
{
return [
'purchase_number' => [
'format' => function () {
return 'PO-' . \Carbon\Carbon::today()->year . '-?'; // autonumber format. '?' will be replaced with the generated number.
},
'length' => 6 // The number of digits in the autonumber
]
];
}