11<?php
22
33use App\Models\ User ;
4+ use Illuminate\Contracts\Auth\ MustVerifyEmail ;
45use Illuminate\Support\Facades\ Auth ;
56use Illuminate\Support\Facades\ Session ;
67use Illuminate\Validation\ Rule ;
8+ use Livewire\Attributes\ Computed ;
79use Livewire\Volt\ Component ;
810
911new class extends Component {
@@ -67,6 +69,19 @@ public function resendVerificationNotification(): void
6769
6870 Session:: flash (' status' , ' verification-link-sent' );
6971 }
72+
73+ # [Computed]
74+ public function hasUnverifiedEmail (): bool
75+ {
76+ return Auth:: user () instanceof MustVerifyEmail && ! Auth:: user ()-> hasVerifiedEmail ();
77+ }
78+
79+ # [Computed]
80+ public function showDeleteUser (): bool
81+ {
82+ return ! Auth:: user () instanceof MustVerifyEmail
83+ || (Auth:: user () instanceof MustVerifyEmail && Auth:: user ()-> hasVerifiedEmail ());
84+ }
7085}; ? >
7186
7287<section class =" w-full" >
@@ -81,7 +96,7 @@ public function resendVerificationNotification(): void
8196 <div >
8297 <flux:input wire:model =" email" :label =" __('Email')" type =" email" required autocomplete =" email" />
8398
84- @if (auth () -> user () instanceof \Illuminate\Contracts\Auth\ MustVerifyEmail && ! auth () -> user () -> hasVerifiedEmail () )
99+ @if ($this -> hasUnverifiedEmail )
85100 <div >
86101 <flux:text class =" mt-4" >
87102 {{ __ (' Your email address is unverified.' ) } }
@@ -113,11 +128,8 @@ public function resendVerificationNotification(): void
113128 </div >
114129 </form >
115130
116- @if (
117- ! auth ()-> user () instanceof \Illuminate\Contracts\Auth\ MustVerifyEmail
118- || (auth ()-> user () instanceof \Illuminate\Contracts\Auth\ MustVerifyEmail && auth ()-> user ()-> hasVerifiedEmail ())
119- )
120- <livewire:settings .delete-user-form />
131+ @if ($this -> showDeleteUser )
132+ <livewire:settings .delete-user-form />
121133 @endif
122134 </x-settings .layout >
123135</section >
0 commit comments