diff --git a/app/Http/Livewire/Profile/Settings/General.php b/app/Http/Livewire/Profile/Settings/General.php new file mode 100644 index 000000000000..249c832458aa --- /dev/null +++ b/app/Http/Livewire/Profile/Settings/General.php @@ -0,0 +1,78 @@ + ['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 = Hash::make($this->password); + } + + $this->profile + ->fill($data) + ->save(); + + $this->saved = ctrans('texts.saved_at', ['time' => now()->toTimeString()]); + } +} diff --git a/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php b/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php new file mode 100644 index 000000000000..ea363872a9f0 --- /dev/null +++ b/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php @@ -0,0 +1,46 @@ + ['required', 'min:3'], + 'website' => ['required', 'url'], + ]; + + public function mount() + { + $this->fill([ + 'profile' => auth()->user('contact')->client, + 'name' => auth()->user('contact')->client->present()->name, + 'website' => auth()->user('contact')->client->present()->website, + 'saved' => ctrans('texts.save'), + ]); + } + + public function render() + { + return render('profile.settings.name-website-logo'); + } + + public function submit() + { + $data = $this->validate($this->rules); + + $this->profile + ->fill($data) + ->save(); + + $this->saved = ctrans('texts.saved_at', ['time' => now()->toTimeString()]); + } +} diff --git a/app/Http/Livewire/Profile/Settings/PersonalAddress.php b/app/Http/Livewire/Profile/Settings/PersonalAddress.php new file mode 100644 index 000000000000..7cd0030fcd81 --- /dev/null +++ b/app/Http/Livewire/Profile/Settings/PersonalAddress.php @@ -0,0 +1,62 @@ + ['required'], + 'address2' => ['required'], + 'city' => ['required'], + 'state' => ['required'], + 'postal_code' => ['required'], + 'country_id' => ['required'], + ]; + + public function mount($countries) + { + $this->fill([ + 'profile' => auth()->user('contact')->client, + 'address1' => auth()->user('contact')->client->address1, + 'address2' => auth()->user('contact')->client->address2, + 'city' => auth()->user('contact')->client->city, + 'state' => auth()->user('contact')->client->state, + 'postal_code' => auth()->user('contact')->client->postal_code, + 'country_id' => auth()->user('contact')->client->country_id, + + 'countries' => $countries, + 'saved' => ctrans('texts.save'), + ]); + } + + public function render() + { + return render('profile.settings.personal-address'); + } + + public function submit() + { + $data = $this->validate($this->rules); + + $this->profile + ->fill($data) + ->save(); + + $this->saved = ctrans('texts.saved_at', ['time' => now()->toTimeString()]); + } +} diff --git a/app/Http/Livewire/Profile/Settings/ShippingAddress.php b/app/Http/Livewire/Profile/Settings/ShippingAddress.php new file mode 100644 index 000000000000..39ce3aec426e --- /dev/null +++ b/app/Http/Livewire/Profile/Settings/ShippingAddress.php @@ -0,0 +1,62 @@ + ['required'], + 'shipping_address2' => ['required'], + 'shipping_city' => ['required'], + 'shipping_state' => ['required'], + 'shipping_postal_code' => ['required'], + 'shipping_country_id' => ['required'], + ]; + + public function mount($countries) + { + $this->fill([ + 'profile' => auth()->user('contact')->client, + 'shipping_address1' => auth()->user('contact')->client->shipping_address1, + 'shipping_address2' => auth()->user('contact')->client->shipping_address2, + 'shipping_city' => auth()->user('contact')->client->shipping_city, + 'shipping_state' => auth()->user('contact')->client->shipping_state, + 'shipping_postal_code' => auth()->user('contact')->client->shipping_postal_code, + 'shipping_country_id' => auth()->user('contact')->client->shipping_country_id, + + 'countries' => $countries, + 'saved' => ctrans('texts.save'), + ]); + } + + public function render() + { + return render('profile.settings.shipping-address'); + } + + public function submit() + { + $data = $this->validate($this->rules); + + $this->profile + ->fill($data) + ->save(); + + $this->saved = ctrans('texts.saved_at', ['time' => now()->toTimeString()]); + } +} diff --git a/composer.json b/composer.json index 4df67077406e..2b584ceebb40 100644 --- a/composer.json +++ b/composer.json @@ -103,7 +103,8 @@ ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover --ansi" + "@php artisan package:discover --ansi", + "@php artisan vendor:publish --force --tag=livewire:assets --ansi" ] }, "config": { 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..e2a715303c84 100644 --- a/resources/views/portal/ninja2020/profile/index.blade.php +++ b/resources/views/portal/ninja2020/profile/index.blade.php @@ -7,355 +7,15 @@ @endsection @section('body') - -
- @lang('texts.client_information_text') -
-- {{ ctrans('texts.make_sure_use_full_link') }} -
-- {{ ctrans('texts.enter_your_personal_address') }} -
-- {{ ctrans('texts.enter_your_shipping_address') }} -
-+ {{ ctrans('texts.client_information_text') }} +
++ {{ ctrans('texts.make_sure_use_full_link') }} +
++ {{ ctrans('texts.enter_your_personal_address') }} +
++ {{ ctrans('texts.enter_your_shipping_address') }} +
+