Hi, I’m new programming and using yii2.
I have a model like this:
For the first time my client handle one type of consecutive(99-9999). But now he wants handle another 2 type of consecutive (99-M-999,99-L-999).
I need your help. I have no idea how to handle 3 different consecutive types. Do I need to use a new model for each new correlative ?. Help me
the problem is not clear.
I mean, for now I have this:
Id. Correlative. description
Can I do this?
Id. Correlative. Description
I don’t now how to increment every correlative in the same model, I think I must create a model for every different correlative
You dont need to create a new model.
You should implement some logic to solve the problem. For example you could:
Get last record from DB;
Explode all the “-” in the value fetched;
Get the index of the exploded string(es.for string NN-S-NNN );
for every index use increment function(+) to count string /character and number.
$s = “A”;
$s++; ($s is B now)
//The same is for number;
rebuild your string as your initial pattern (NN-S-NNN)
save the record;
That is a minimal logic example to solve you problem.
Try to code the flow!