Created
September 15, 2023 19:36
-
-
Save juque/e27b57e0ac97a0a3f7beff379cf29619 to your computer and use it in GitHub Desktop.
Laravel: Set new password to user role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \App\Models\User; | |
use Illuminate\Support\Str; | |
$users = User::where('role', 'user')->get(); | |
foreach($users as $user) { | |
$newPassword = Str::random(12); | |
$user->password = bcrypt($newPassword); | |
$user->save(); | |
printf("%s,%s\n", $user->email, $newPassword); | |
} | |
foreach($users as $user) { | |
printf("%s,%s\n", $user->email, $user->name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment