File: /home/imensosw/www/mpl.imenso.co/app/Console/Commands/UpdateAdminPasswords.php
<?php
namespace App\Console\Commands;
use App\Models\User;
use Faker\Factory;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
class UpdateAdminPasswords extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mpl:update-admin-passwords';
/**
* The console command description.
*
* @var string
*/
protected $description = 'This command seeds all admin accounts on MPL with a fresh password.';
protected $passwords = [];
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$faker = Factory::create();
User::where('type_id', 5)
->each(function ($user) use ($faker) {
$password = $faker->word().$faker->word().$faker->randomLetter.$faker->numberBetween(9, 56);
$user->password = Hash::make($password);
$user->save();
$this->passwords[$user->email] = $password;
});
$this->info('In no particular order, here are the freshly generated passwords:');
foreach ($this->passwords as $email => $password) {
$this->line("{$email} - $password");
}
}
}