diff --git a/app/Http/Livewire/Profile/Settings/General.php b/app/Http/Livewire/Profile/Settings/General.php new file mode 100644 index 000000000000..ad875c910ec8 --- /dev/null +++ b/app/Http/Livewire/Profile/Settings/General.php @@ -0,0 +1,77 @@ + ['required'], + 'last_name' => ['required'], + 'email' => ['required', 'email'], + ]; + + public function mount() + { + $profile = auth()->user('contact'); + + $this->fill([ + 'profile' => $profile, + 'first_name' => $profile->first_name, + 'last_name' => $profile->last_name, + 'email' => $profile->email, + 'phone' => $profile->phone, + 'saved' => ctrans('texts.save'), + ]); + } + + public function render() + { + return render('profile.settings.general'); + } + + public function submit() + { + if ($this->profile->email != $this->email) { + $this->rules['email'][] = 'unique:client_contacts,email'; + } + + if (!empty($this->password)) { + $this->rules['password'] = ['sometimes', 'nullable', 'required', 'min:6', 'confirmed']; + } + + $data = $this->validate($this->rules); + + if (!empty($this->password)) { + $this->profile->password = encrypt($this->password); + } + + $this->profile + ->fill($data) + ->save(); + + $this->saved = ctrans('texts.saved_at', ['time' => now()->toTimeString()]); + } +} diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index ea2eec4f6e60..4d5e8e7e77eb 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3279,4 +3279,6 @@ return [ 'over_payments_disabled' => 'Company doesn\'t support over payments.', 'paused' => 'Paused', + + 'saved_at' => 'Saved at :time', ]; diff --git a/resources/views/portal/ninja2020/profile/index.blade.php b/resources/views/portal/ninja2020/profile/index.blade.php index 3a7ce9549df8..0914c3a5d36a 100644 --- a/resources/views/portal/ninja2020/profile/index.blade.php +++ b/resources/views/portal/ninja2020/profile/index.blade.php @@ -7,100 +7,8 @@ @endsection @section('body') - -
- @lang('texts.client_information_text') -
-+ {{ ctrans('texts.client_information_text') }} +
+