change test user pass
This commit is contained in:
parent
9e47b399ed
commit
f976b4d6ef
37
database/seeders/UpdateTestUserPasswordSeeder.php
Normal file
37
database/seeders/UpdateTestUserPasswordSeeder.php
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?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}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user