1. Go to this page and download the library: Download mdmsoft/yii2-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/ */
mdmsoft / yii2-autonumber example snippets
public function behaviors()
{
return [
[
'class' => 'mdm\autonumber\Behavior',
'attribute' => 'sales_num', // ated number
'digit' => 4 // optional, default to null.
],
];
}
// it will set value $model->sales_num as 'SA.2014-06-25.0001'
public function rules()
{
return [
[['sales_num'], 'autonumber', 'format'=>'SA.'.date('Y-m-d').'.?'],
...
];
}
public function rules()
{
return [
[['sales_num'], 'autonumber', 'format' => 'SA/{Y/m}/?.???'],
...
];
}
// it will set value $model->sales_num as 'SA/2019/10/0.001'
public function behaviors()
{
return [
[
'class' => 'class' => 'mdm\autonumber\Behavior',
'attribute' => 'sales_num', //
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.