Good morning, I have a question regarding the while
function in my Laravel project.
It works like this:
User has an X number of credits - credits column in the database. It upa 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 created user (or each line read) the credit of the user_river 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 the system to stop and display a message when the number of credits was 0 or less than the number of lines. I do not know if it is right what I did, but I went searching the internet.