delete-user-form.blade.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. use App\Livewire\Actions\Logout;
  3. use Illuminate\Support\Facades\Auth;
  4. use Livewire\Volt\Component;
  5. new class extends Component
  6. {
  7. public string $password = '';
  8. /**
  9. * Delete the currently authenticated user.
  10. */
  11. public function deleteUser(Logout $logout): void
  12. {
  13. $this->validate([
  14. 'password' => ['required', 'string', 'current_password'],
  15. ]);
  16. tap(Auth::user(), $logout(...))->delete();
  17. $this->redirect('/', navigate: true);
  18. }
  19. }; ?>
  20. <section class="space-y-6">
  21. <header>
  22. <h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
  23. {{ __('Delete Account') }}
  24. </h2>
  25. <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
  26. {{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.') }}
  27. </p>
  28. </header>
  29. <x-danger-button
  30. x-data=""
  31. x-on:click.prevent="$dispatch('open-modal', 'confirm-user-deletion')"
  32. >{{ __('Delete Account') }}</x-danger-button>
  33. <x-modal name="confirm-user-deletion" :show="$errors->isNotEmpty()" focusable>
  34. <form wire:submit="deleteUser" class="p-6">
  35. <h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
  36. {{ __('Are you sure you want to delete your account?') }}
  37. </h2>
  38. <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
  39. {{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.') }}
  40. </p>
  41. <div class="mt-6">
  42. <x-input-label for="password" value="{{ __('Password') }}" class="sr-only" />
  43. <x-text-input
  44. wire:model="password"
  45. id="password"
  46. name="password"
  47. type="password"
  48. class="mt-1 block w-3/4"
  49. placeholder="{{ __('Password') }}"
  50. />
  51. <x-input-error :messages="$errors->get('password')" class="mt-2" />
  52. </div>
  53. <div class="mt-6 flex justify-end">
  54. <x-secondary-button x-on:click="$dispatch('close')">
  55. {{ __('Cancel') }}
  56. </x-secondary-button>
  57. <x-danger-button class="ms-3">
  58. {{ __('Delete Account') }}
  59. </x-danger-button>
  60. </div>
  61. </form>
  62. </x-modal>
  63. </section>