Skip to content

tkj45/yii2-autonumber

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Number Extension for Yii 2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist mdmsoft/yii2-autonumber "*"

or add

"mdmsoft/yii2-autonumber": "*"

to the require section of your composer.json file.

Usage

Prepare required table by execute yii migrate.

yii migrate --migrationPath=@mdm/autonumber/migrations

Once the extension is installed, simply modify your active record definision class:

public function behavior()
{
	return [
		[
			'class' => 'mdm\autonumber\Behavior',
			'attribute' => 'sales_num', // required
			'group' => 'sales', // required, unique
			'value' => 'SA-'.date('Y-m-d').'?' , // format auto number. '?' will be replaced with generated number
			'digit' => 4 // optional, default to null. 
		],
		...
	];
}

About

Yii2 extension to generate auto number

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published