hash = $hash; } public function handle(): void { /** @var User|null $user */ $user = User::where('is_admin', true)->first(); if (!$user) { $this->error('An admin account cannot be found. Have you set up Koel yet?'); return; } $this->comment("Changing the default admin's password (ID: {$user->id}, email: {$user->email})"); do { $password = $this->secret('New password'); $confirmedPassword = $this->secret('Again, just to be sure'); } while (!$this->validatePasswords($password, $confirmedPassword)); $user->password = $this->hash->make($password); $user->save(); $this->comment('New password saved, enjoy! 👌'); } private function validatePasswords(?string $password, ?string $confirmedPassword): bool { if (!$password || !$confirmedPassword) { $this->error('Passwords cannot be empty. You know that.'); return false; } if (strcmp($password, $confirmedPassword) !== 0) { $this->error('The passwords do not match. Try again maybe?'); return false; } return true; } }