delete-user-form.blade.php (2612B)
1 <?php 2 3 use Livewire\Attributes\Rule; 4 use Livewire\Volt\Component; 5 6 new class extends Component 7 { 8 #[Rule(['required', 'string', 'current_password'])] 9 public string $password = ''; 10 11 public function deleteUser(): void 12 { 13 $this->validate(); 14 15 tap(auth()->user(), fn () => auth()->logout())->delete(); 16 17 session()->invalidate(); 18 session()->regenerateToken(); 19 20 $this->redirect('/', navigate: true); 21 } 22 }; ?> 23 24 <section class="space-y-6"> 25 <header> 26 <h2 class="text-lg font-medium text-gray-900 dark:text-gray-100"> 27 {{ __('Delete Account') }} 28 </h2> 29 30 <p class="mt-1 text-sm text-gray-600 dark:text-gray-400"> 31 {{ __('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.') }} 32 </p> 33 </header> 34 35 <x-danger-button 36 x-data="" 37 x-on:click.prevent="$dispatch('open-modal', 'confirm-user-deletion')" 38 >{{ __('Delete Account') }}</x-danger-button> 39 40 <x-modal name="confirm-user-deletion" :show="$errors->isNotEmpty()" focusable> 41 <form wire:submit="deleteUser" class="p-6"> 42 43 <h2 class="text-lg font-medium text-gray-900 dark:text-gray-100"> 44 {{ __('Are you sure you want to delete your account?') }} 45 </h2> 46 47 <p class="mt-1 text-sm text-gray-600 dark:text-gray-400"> 48 {{ __('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.') }} 49 </p> 50 51 <div class="mt-6"> 52 <x-input-label for="password" value="{{ __('Password') }}" class="sr-only" /> 53 54 <x-text-input 55 wire:model="password" 56 id="password" 57 name="password" 58 type="password" 59 class="mt-1 block w-3/4" 60 placeholder="{{ __('Password') }}" 61 /> 62 63 <x-input-error :messages="$errors->get('password')" class="mt-2" /> 64 </div> 65 66 <div class="mt-6 flex justify-end"> 67 <x-secondary-button x-on:click="$dispatch('close')"> 68 {{ __('Cancel') }} 69 </x-secondary-button> 70 71 <x-danger-button class="ml-3"> 72 {{ __('Delete Account') }} 73 </x-danger-button> 74 </div> 75 </form> 76 </x-modal> 77 </section>