user = Auth::user(); if (!$this->user) { return redirect()->route('login'); } $this->profile = UserProfile::getForUser($this->user->id); // If no profile exists, create one for settings if (!$this->profile) { $this->profile = UserProfile::createForUser($this->user->id); } // Load current settings $this->is_public = $this->profile->is_public; $this->show_email = $this->profile->show_email; $this->show_joined_date = $this->profile->show_joined_date; $this->allow_comments = $this->profile->allow_comments; } public function save() { $this->profile->update([ 'is_public' => $this->is_public, 'show_email' => $this->show_email, 'show_joined_date' => $this->show_joined_date, 'allow_comments' => $this->allow_comments, ]); session()->flash('message', 'Settings updated successfully!'); } public function render() { return view('socialbase::livewire.profile-settings'); } }