43 lines
980 B
PHP
43 lines
980 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\UserStaff;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class HashStaffPasswords extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'app:hash-staff-passwords';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Hash all passwords in UserStaff table to password123';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$count = 0;
|
|
$staffUsers = UserStaff::all();
|
|
|
|
foreach ($staffUsers as $staff) {
|
|
$staff->password = Hash::make('password123');
|
|
$staff->save();
|
|
$count++;
|
|
$this->line("✓ Hashed password for: {$staff->nama} (NIP: {$staff->nip})");
|
|
}
|
|
|
|
$this->info("\n✅ Successfully hashed {$count} staff passwords");
|
|
}
|
|
}
|