2017 © Pedro Peláez
 

yii2-extension yii2-autonumber

Auto number extension for the Yii framework + Enhacement

image

bahirul/yii2-autonumber

Auto number extension for the Yii framework + Enhacement

  • Friday, July 20, 2018
  • by bahirul
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Auto Number Extension for Yii 2

Yii2 extension to genarete formated autonumber. It can be used for generate document number., (*1)

This extension forked from mdm/yii2-autonumber with some mods., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist bahirul/yii2-autonumber "~1.0"

or add, (*5)

"bahirul/yii2-autonumber": "~1.0"

to the require section of your composer.json file., (*6)

Usage

Prepare required table by execute yii migrate., (*7)

yii migrate --migrationPath=@bahirul/yii2/autonumber/migrations

if wantn't use db migration. you can create required table manually., (*8)

CREATE TABLE auto_number (
    "group" varchar(32) NOT NULL,
    "number" int,
    optimistic_lock int,
    update_time int,
    PRIMARY KEY ("group")
);

Once the extension is installed, simply modify your ActiveRecord class:, (*9)

public function behaviors()
{
    return [
        [
            'class' => 'bahirul\yii2\autonumber\Behavior',
            'attribute' => 'sales_num', // required
            'group' => $this->id_branch, // optional
            'value' => 'SA.'.date('Y-m-d').'.?' , // format auto number. '?' will be replaced with generated number or you can use " 'value' => function($event){ return 'SA.'.date('Y-m-d').'.?' } " as long the return value contain '?' character
            'digit' => 4 // optional, default to null. 
        ],
    ];
}

// it will set value $model->sales_num as 'SA.2014-06-25.0001'

Instead of behavior, you can use this extension as validator, (*10)

public function rules()
{
    return [
        [['sales_num'], 'autonumber', 'format'=>'SA.'.date('Y-m-d').'.?'],
        ...
    ];
}

The Versions

20/07 2018

dev-master

9999999-dev

Auto number extension for the Yii framework + Enhacement

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul D Munir

yii2 extension behavior autonumber

20/07 2018

1.5

1.5.0.0

Auto number extension for the Yii framework + Enhacement

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul D Munir

yii2 extension behavior autonumber

06/02 2016

1.4

1.4.0.0

Auto number extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul D Munir

yii2 extension behavior autonumber

02/02 2016

1.3

1.3.0.0

Auto number extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul D Munir

yii2 extension behavior autonumber

26/07 2015

1.2

1.2.0.0

Auto number extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul D Munir

yii2 extension behavior autonumber

23/07 2015

1.1

1.1.0.0

Auto number extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul D Munir

yii2 extension behavior autonumber

02/11 2014

1.0.0

1.0.0.0

Auto number extension for the Yii framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul D Munir

yii2 extension behavior autonumber