Files
BauIN/app/Livewire/Settings/Profile.php
T
ChristophandClaude Opus 5.5 b297518810 Flux durch TallStackUI 4 ersetzt
- TallStackUI 4 (MIT) statt Flux; Komponenten mit Präfix ts- (<x-ts-…>)
- Layouts, Login-, Passwort-, 2FA- und Einstellungsseiten neu aufgebaut
- Livewire-Skripte explizit in beiden Layouts, damit Alpine auch auf den
  Fortify-Seiten ohne Livewire-Komponente läuft
- Dark Mode über tallstackui_darkTheme(), ohne Aufblitzen beim Laden
- Registrierungs-View und ungenutzte Layout-Varianten entfernt
- Test: Seiten laden keine Ressourcen von fremden Hosts (Vorgabe "alles lokal")

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 09:33:26 +02:00

85 lines
1.9 KiB
PHP

<?php
namespace App\Livewire\Settings;
use App\Concerns\ProfileValidationRules;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Title;
use Livewire\Component;
use TallStackUi\Traits\Interactions;
#[Title('Profile settings')]
class Profile extends Component
{
use Interactions, ProfileValidationRules;
public string $name = '';
public string $email = '';
/**
* Mount the component.
*/
public function mount(): void
{
$this->name = Auth::user()->name;
$this->email = Auth::user()->email;
}
/**
* Update the profile information for the currently authenticated user.
*/
public function updateProfileInformation(): void
{
$user = Auth::user();
$validated = $this->validate($this->profileRules($user->id));
$user->fill($validated);
if ($user->isDirty('email')) {
$user->email_verified_at = null;
}
$user->save();
$this->toast()->success(__('Profile updated.'))->send();
}
/**
* Send an email verification notification to the current user.
*/
public function resendVerificationNotification(): void
{
$user = Auth::user();
if ($user->hasVerifiedEmail()) {
$this->redirectIntended(default: route('dashboard', absolute: false));
return;
}
$user->sendEmailVerificationNotification();
$this->toast()->info(__('A new verification link has been sent to your email address.'))->send();
}
#[Computed]
public function hasUnverifiedEmail(): bool
{
$user = Auth::user();
return $user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail();
}
#[Computed]
public function showDeleteUser(): bool
{
$user = Auth::user();
return ! $user instanceof MustVerifyEmail || $user->hasVerifiedEmail();
}
}