Teren-app/database/seeders/UpdateTestUserPasswordSeeder.php
2025-11-06 21:54:07 +01:00

39 lines
981 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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}.");
}
}