dev-master
9999999-devExperemental extension that allows you to numerate whatever in your app
CC-0
The Requires
- php >=5.4.0
- yiisoft/yii2 2.0.5
db numerator numeration
Experemental extension that allows you to numerate whatever in your app
rapidly creating small projects., (*1)
The template contains the basic features including user login/logout and a contact page. It includes all commonly used configurations that would allow you to focus on adding new features to your application., (*2)
The minimum requirement by this extension that your Web server supports PHP 5.4.0., (*4)
If you do not have Composer, you may install it by following the instructions at getcomposer.org., (*5)
You can then install this extension using the following command:, (*6)
php composer.phar require novikas/yii2-numerator: "@dev"
First of all you need to execute migrations that is located in extensions directory:, (*7)
yii mirate --migrationsPath = @novikas/numerator/migrations
To create new simple numerator template, you need to call Numerator::createNumerator($config) just once. Argument config is an array:, (*8)
Numerator::createNumerator([ 'name' => 'doc_numerator1', 'model_class' => 'common\models\Doc', 'field' => 'number', 'type_field' => 'type', 'type_value' => 1, 'mask' => '{УК-}999', 'init_val' => 55 ]);
If your models differs from each other by more than on field (property), you can use the following template:, (*9)
Numerator::createNumerator([ 'name' => 'doc_numerator2', 'model_class' => 'common\models\Doc', 'field' => 'number', 'type_field' => 'type1&type2', 'type_value' => "1&2", 'mask' => '{UK-}999', 'init_val' => 2 ]);
So, according this template numerator will numerate your models by following condition, (*10)
WHERE type1 = 1 AND type2 = 2
NOTE Note that values of the properties Numerator::type_value and Numerator::type_field must corresponds., (*11)
If your models differs in properties of their relations, you can use the following template:, (*12)
Numerator::createNumerator([ 'name' => 'doc_numerator2', 'model_class' => 'common\models\Doc', 'field' => 'number', 'type_field' => 'doc.type1&store.type2', 'type_value' => "1&2", 'mask' => '{UK-}999', 'init_val' => 2, 'join_table' => 'store', 'join_on_condition' => 'doc.FK_store=store.id' ]);
NOTE Note that you need to set properties Numerator::join_table and Numerator::join_on_condition. Also it's recommended to add table prefix in property type_field to avoid ambiguity., (*13)
After you created all templates for your models, you can use Numerator as the following code:, (*14)
$numerator = Numerator::getNumerator($templateName); $doc->number = $numerator->nextNumber();
This code could be place in rules of models as a default value for number property for example., (*15)
Experemental extension that allows you to numerate whatever in your app
CC-0
db numerator numeration