-2
Good morning, I have a question about the function while
in my project Laravel.
Here’s how it works:
User has an X number of credits - column credits in the database. It uses an xlsx file with the data of new users, the system counts the number of lines ($rows
) and opens a foreach
to access each line and create a user.
The idea is that each user was worth 1 credit - that is - for each user created (or each line read) the user’s credit_creator reduced by 1 until it reached the value of 0 and the system stopped.
$credito = $usuarioLogado->creditos;
$linhas_tabela = $dadosPlanilha->count();
do { (código de criação do novo usuário) $credito--; } while ($credito >= $linhas_tabela;
I wanted that when the number of credits is 0 or less than the number of lines, the system would stop and present a message. I don’t know if it’s right what I did, but I’ve been doing an Internet search.
What would be the doubt? Have how to post what developed?
– Rafael Salomão