From 554e5952111350307324bcc83f88f71add2771a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 24 Sep 2020 14:23:05 +0200 Subject: [PATCH] Profile settings: Shipping address --- .../Profile/Settings/PersonalAddress.php | 62 ++++++++++++ .../portal/ninja2020/profile/index.blade.php | 98 +------------------ .../settings/name-website-logo.blade.php | 1 - .../settings/personal-address.blade.php | 84 ++++++++++++++++ 4 files changed, 147 insertions(+), 98 deletions(-) create mode 100644 app/Http/Livewire/Profile/Settings/PersonalAddress.php create mode 100644 resources/views/portal/ninja2020/profile/settings/personal-address.blade.php diff --git a/app/Http/Livewire/Profile/Settings/PersonalAddress.php b/app/Http/Livewire/Profile/Settings/PersonalAddress.php new file mode 100644 index 0000000000..6a1488a249 --- /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' => optional(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/resources/views/portal/ninja2020/profile/index.blade.php b/resources/views/portal/ninja2020/profile/index.blade.php index 6cb2d546ae..4197ac83f7 100644 --- a/resources/views/portal/ninja2020/profile/index.blade.php +++ b/resources/views/portal/ninja2020/profile/index.blade.php @@ -14,103 +14,7 @@ @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])
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 index 4e731dc9f8..177319bafe 100644 --- a/resources/views/portal/ninja2020/profile/settings/name-website-logo.blade.php +++ b/resources/views/portal/ninja2020/profile/settings/name-website-logo.blade.php @@ -12,7 +12,6 @@
@csrf - @method('PUT')
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 0000000000..e651266777 --- /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 +
+
+
+
+ +
+
+ +
+