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') - -
-
-
-
-

{{ ctrans('texts.profile') }}

-

- @lang('texts.client_information_text') -

-
-
-
-
- @csrf - @method('PUT') -
-
-
-
- - - @error('first_name') -
- {{ $message }} -
- @enderror -
- -
- - - @error('last_name') -
- {{ $message }} -
- @enderror -
- -
- - - @error('email') -
- {{ $message }} -
- @enderror -
- -
- - - @error('phone') -
- {{ $message }} -
- @enderror -
- -
- - - @error('password') -
- {{ $message }} -
- @enderror -
- -
- - - @error('password_confirmation') -
- {{ $message }} -
- @enderror -
-
-
-
- -
-
-
-
-
-
- + @livewire('profile.settings.general') + -
-
-
-
-

{{ ctrans('texts.name_website_logo') }}

-

- {{ ctrans('texts.make_sure_use_full_link') }} -

-
-
-
-
- @csrf - @method('PUT') -
-
-
-
- - - @error('name') -
- {{ $message }} -
- @enderror -
-
- - - @error('website') -
- {{ $message }} -
- @enderror -
- -
-
-
- -
-
-
-
-
-
+ @livewire('profile.settings.name-website-logo') -
-
-
-
-

{{ ctrans('texts.personal_address') }}

-

- {{ ctrans('texts.enter_your_personal_address') }} -

-
-
-
-
- @csrf - @method('PUT') -
-
-
-
- - - @error('address1') -
- {{ $message }} -
- @enderror -
-
- - - @error('address2') -
- {{ $message }} -
- @enderror -
-
- - - @error('city') -
- {{ $message }} -
- @enderror -
-
- - - @error('state') -
- {{ $message }} -
- @enderror -
-
- - - @error('postal_code') -
- {{ $message }} -
- @enderror -
-
- - - @error('country') -
- {{ $message }} -
- @enderror -
-
-
-
- -
-
-
-
-
-
+ @livewire('profile.settings.personal-address', ['countries' => $countries]) -
-
-
-
-

{{ ctrans('texts.shipping_address') }}

-

- {{ ctrans('texts.enter_your_shipping_address') }} -

-
-
-
-
- @csrf - @method('PUT') -
-
-
-
- - - @error('shipping_address1') -
- {{ $message }} -
- @enderror -
-
- - - @error('shipping_address2') -
- {{ $message }} -
- @enderror -
-
- - - @error('shipping_city') -
- {{ $message }} -
- @enderror -
-
- - - @error('shipping_state') -
- {{ $message }} -
- @enderror -
-
- - - @error('shipping_postal_code') -
- {{ $message }} -
- @enderror -
-
- - - @error('country') -
- {{ $message }} -
- @enderror -
-
-
-
- -
-
-
-
-
-
- + @livewire('profile.settings.shipping-address', ['countries' => $countries]) @endsection diff --git a/resources/views/portal/ninja2020/profile/settings/general.blade.php b/resources/views/portal/ninja2020/profile/settings/general.blade.php new file mode 100644 index 000000000000..9d7c3b5f2a7b --- /dev/null +++ b/resources/views/portal/ninja2020/profile/settings/general.blade.php @@ -0,0 +1,87 @@ +
+
+
+
+

{{ ctrans('texts.profile') }}

+

+ {{ ctrans('texts.client_information_text') }} +

+
+
+ +
+
+ @csrf + @method('PUT') +
+
+
+
+ + + @error('first_name') +
+ {{ $message }} +
+ @enderror +
+ +
+ + + @error('last_name') +
+ {{ $message }} +
+ @enderror +
+ +
+ + + @error('email') +
+ {{ $message }} +
+ @enderror +
+ +
+ + + @error('phone') +
+ {{ $message }} +
+ @enderror +
+ +
+ + + @error('password') +
+ {{ $message }} +
+ @enderror +
+ +
+ + + @error('password_confirmation') +
+ {{ $message }} +
+ @enderror +
+
+
+
+ +
+
+
+
+
+
diff --git a/resources/views/portal/ninja2020/profile/settings/name-website-logo.blade.php b/resources/views/portal/ninja2020/profile/settings/name-website-logo.blade.php new file mode 100644 index 000000000000..177319bafe87 --- /dev/null +++ b/resources/views/portal/ninja2020/profile/settings/name-website-logo.blade.php @@ -0,0 +1,46 @@ +
+
+
+
+

{{ ctrans('texts.name_website_logo') }}

+

+ {{ ctrans('texts.make_sure_use_full_link') }} +

+
+
+ +
+
+ @csrf +
+
+
+
+ + + @error('name') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('website') +
+ {{ $message }} +
+ @enderror +
+ +
+
+
+ +
+
+
+
+
+
diff --git a/resources/views/portal/ninja2020/profile/settings/personal-address.blade.php b/resources/views/portal/ninja2020/profile/settings/personal-address.blade.php new file mode 100644 index 000000000000..e65126677740 --- /dev/null +++ b/resources/views/portal/ninja2020/profile/settings/personal-address.blade.php @@ -0,0 +1,84 @@ +
+
+
+
+

{{ ctrans('texts.personal_address') }}

+

+ {{ ctrans('texts.enter_your_personal_address') }} +

+
+
+
+
+ @csrf +
+
+
+ + + @error('address1') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('address2') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('city') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('state') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('postal_code') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('country') +
+ {{ $message }} +
+ @enderror +
+
+
+
+ +
+
+ +
+
diff --git a/resources/views/portal/ninja2020/profile/settings/shipping-address.blade.php b/resources/views/portal/ninja2020/profile/settings/shipping-address.blade.php new file mode 100644 index 000000000000..40fe14053507 --- /dev/null +++ b/resources/views/portal/ninja2020/profile/settings/shipping-address.blade.php @@ -0,0 +1,88 @@ +
+
+
+
+

{{ ctrans('texts.shipping_address') }}

+

+ {{ ctrans('texts.enter_your_shipping_address') }} +

+
+
+
+
+ @csrf +
+
+
+
+ + + @error('shipping_address1') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('shipping_address2') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('shipping_city') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('shipping_state') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('shipping_postal_code') +
+ {{ $message }} +
+ @enderror +
+
+ + + @error('country') +
+ {{ $message }} +
+ @enderror +
+
+
+
+ +
+
+
+
+
+