39 lines
981 B
PHP
39 lines
981 B
PHP
<?php
|
||
|
||
namespace Database\Seeders;
|
||
|
||
use App\Models\User;
|
||
use Illuminate\Database\Seeder;
|
||
|
||
class UpdateTestUserPasswordSeeder extends Seeder
|
||
{
|
||
/**
|
||
* Update password for the test user (idempotent & safe to re-run).
|
||
*/
|
||
public function run(): void
|
||
{
|
||
$email = 'test@example.com';
|
||
|
||
// Set the new password here. User model casts 'password' => 'hashed', so plain text is fine.
|
||
$newPassword = 'ThisUse3*rNo32N3o244'; // <-- modify if you need a different password
|
||
|
||
$user = User::where('email', $email)->first();
|
||
|
||
if (! $user) {
|
||
$this->command?->warn("User {$email} not found – nothing updated.");
|
||
|
||
return;
|
||
}
|
||
|
||
$user->password = $newPassword; // Will be hashed automatically by cast
|
||
|
||
if ($user->email_verified_at === null) {
|
||
$user->email_verified_at = now();
|
||
}
|
||
|
||
$user->save();
|
||
|
||
$this->command?->info("Password updated for {$email}.");
|
||
}
|
||
}
|