From abcf105d071809a93a7b8c96f49b9eb7c768a39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Thu, 2 Jul 2026 10:32:02 +0300 Subject: [PATCH] feat: add intern panel navigation link and user password reset CLI command --- app/Console/Commands/ResetUserPassword.php | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 app/Console/Commands/ResetUserPassword.php diff --git a/app/Console/Commands/ResetUserPassword.php b/app/Console/Commands/ResetUserPassword.php new file mode 100644 index 0000000..b0b5776 --- /dev/null +++ b/app/Console/Commands/ResetUserPassword.php @@ -0,0 +1,77 @@ +argument('email') ?: $this->ask('Kullanıcının e-posta adresini giriniz:'); + + if (empty($email)) { + $this->error('E-posta adresi boş olamaz!'); + return self::FAILURE; + } + + // Email formatını kontrol et + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + $this->error('Geçersiz e-posta formatı!'); + return self::FAILURE; + } + + // Kullanıcıyı bul + $user = User::where('email', $email)->first(); + + if (!$user) { + $this->error("E-posta adresi '{$email}' ile kayıtlı kullanıcı bulunamadı!"); + return self::FAILURE; + } + + // Şifreyi al veya sor ya da rastgele oluştur + $password = $this->argument('password'); + + if ($password === null) { + if ($this->confirm('Yeni şifreyi otomatik rastgele mi üretelim (6 haneli rakamsal)?', true)) { + $password = (string) random_int(100000, 999999); + } else { + $password = $this->secret('Yeni şifreyi giriniz:'); + if (empty($password)) { + $this->error('Şifre boş olamaz!'); + return self::FAILURE; + } + } + } + + // Şifreyi güncelle ve kaydet + $user->password = Hash::make($password); + $user->save(); + + $this->info("✓ Kullanıcı '{$user->name}' ({$user->email}) şifresi başarıyla güncellendi!"); + $this->info("Yeni Şifre: {$password}"); + + return self::SUCCESS; + } +}