Generate consecutive number of 10 digits as 0000000001 and auto-join with Laravel?

-1

My question is how I can get a consecutive from 0000000001 and go autoincrementando, as it would normally be without additional zeros.

    
asked by Gustavo 11.12.2018 в 16:48
source

1 answer

0

The part where you say you need to auto-increase ... I do not know how you want to do it (do you say it for something from DB?). Based on that, the answer could change, but in the absence of more information, I think what you ask could be done like this:

$numero = 12345; //tu numero
$numero_final = str_pad($numero, 10, '0', STR_PAD_LEFT); // "0000012345"

Si lo necesitas autoincrementar, no tienes más que hacer:
$numero_final++; // 12346
$numero_final = str_pad($numero_final, 10, '0', STR_PAD_LEFT); // "0000012346"
    
answered by 11.12.2018 в 18:48