1. Go to this page and download the library: Download alfa6661/laravel-autonumber library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
useAlfa6661\AutoNumber\AutoNumberTrait;
classOrderextendsModel{
useAutoNumberTrait;
/**
* Return the autonumber configuration array for this model.
*
* @return array
*/publicfunctiongetAutoNumberOptions(){
return [
'order_number' => [
'format' => 'SO.?', // autonumber format. '?' will be replaced with the generated number.'length' => 5// The number of digits in an autonumber
]
];
}
}
publicfunctiongetAutoNumberOptions(){
return [
'order_number' => [
'format' => function(){
return'SO/' . date('Ymd') . '/?'; // autonumber format. '?' will be replaced with the generated number.
},
'length' => 5// The number of digits in the autonumber
]
];
}