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.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Alfa6661\AutoNumber\AutoNumberTrait;
class Order extends Model
{
use AutoNumberTrait;
/**
* Return the autonumber configuration array for this model.
*
* @return array
*/
public function getAutoNumberOptions()
{
return [
'order_number' => [
'format' => 'SO.?', // autonumber format. '?' will be replaced with the generated number.
'length' => 5 // The number of digits in an autonumber
]
];
}
}
public function getAutoNumberOptions()
{
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
]
];
}