-1
I need to generate a default password for users of my table login. The password must be the same for all users for the first access to the system. Registration already exists, but I have to modify passwords. The problem happens when updating passwords, only the first user of the table can do the login.
public function recadastroSenha(){
$users = User::whereRaw("flag_del = 0 ")->get();
foreach($users as $user){
$senha = "senha123";
$user->password = bcrypt($senha);
}
$user->save();
}
Even updating all table rows with different encryption, only the first user performs the login.
Insert the
$user->save();
inside the foreach also– Miguel
@Miguel thanks for the answer, I’ve tried this way too and only works with the first record of the table.
– scooby
Remember you’re selecting everyone whose
flag = 0
, is that n is? Anyway the$user->save();
must be inside the foreach, otherwise it will only insert the die for the last$user
who went through theforeach
– Miguel
That, the users with this flag are the "not deleted" in my bd, even saving inside the foreach it seems that the system only accepts a different password for each user, even with different strings.
– scooby
Strange that. And can only enter later with the first $user?
– Miguel
yeah, that’s what happens.
– scooby
I wonder if that’s all there is
flag_del = 0
? try to makeecho $user->password. '<br>';
, to see how many times it prints– Miguel
all are as flag_del and happens to change passwords, I checked now that the first and last registration can access.
– scooby