mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Profile settings: Shipping address
This commit is contained in:
parent
e5183dee56
commit
554e595211
62
app/Http/Livewire/Profile/Settings/PersonalAddress.php
Normal file
62
app/Http/Livewire/Profile/Settings/PersonalAddress.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Profile\Settings;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class PersonalAddress extends Component
|
||||
{
|
||||
public $profile;
|
||||
|
||||
public $address1;
|
||||
public $address2;
|
||||
public $city;
|
||||
public $state;
|
||||
public $postal_code;
|
||||
public $country_id;
|
||||
|
||||
public $countries;
|
||||
|
||||
public $saved;
|
||||
|
||||
protected $rules = [
|
||||
'address1' => ['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()]);
|
||||
}
|
||||
}
|
@ -14,103 +14,7 @@
|
||||
@livewire('profile.settings.name-website-logo')
|
||||
|
||||
<!-- Client personal address -->
|
||||
<div class="mt-10 sm:mt-6">
|
||||
<div class="md:grid md:grid-cols-3 md:gap-6">
|
||||
<div class="md:col-span-1">
|
||||
<div class="sm:px-0">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900">{{ ctrans('texts.personal_address') }}</h3>
|
||||
<p class="mt-1 text-sm leading-5 text-gray-500">
|
||||
{{ ctrans('texts.enter_your_personal_address') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5 md:mt-0 md:col-span-2">
|
||||
<form action="{{ route('client.profile.edit_client', auth()->user()->hashed_id) }}" method="POST"
|
||||
id="update_contact">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="shadow overflow-hidden rounded">
|
||||
<div class="px-4 py-5 bg-white sm:p-6">
|
||||
<div class="grid grid-cols-6 gap-6">
|
||||
<div class="col-span-6 sm:col-span-4">
|
||||
<label for="address1" class="input-label">@lang('texts.address1')</label>
|
||||
<input id="address1" class="input w-full" name="address1"
|
||||
value="{{ auth()->user()->client->address1 }}"/>
|
||||
@error('address1')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-3">
|
||||
<label for="address2" class="input-label">@lang('texts.address2')</label>
|
||||
<input id="address2" class="input w-full" name="address2"
|
||||
value="{{ auth()->user()->client->address2 }}"/>
|
||||
@error('address2')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-3">
|
||||
<label for="city" class="input-label">@lang('texts.city')</label>
|
||||
<input id="city" class="input w-full" name="city"
|
||||
value="{{ auth()->user()->client->city }}"/>
|
||||
@error('city')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-2">
|
||||
<label for="state" class="input-label">@lang('texts.state')</label>
|
||||
<input id="state" class="input w-full" name="state"
|
||||
value="{{ auth()->user()->client->state }}"/>
|
||||
@error('state')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-2">
|
||||
<label for="postal_code" class="input-label">@lang('texts.postal_code')</label>
|
||||
<input id="postal_code" class="input w-full" name="postal_code"
|
||||
value="{{ auth()->user()->client->postal_code }}"/>
|
||||
@error('postal_code')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-2">
|
||||
<label for="country" class="input-label">@lang('texts.country')</label>
|
||||
<select id="country" class="input w-full form-select" name="country">
|
||||
@foreach($countries as $country)
|
||||
<option
|
||||
{{ $country == isset(auth()->user()->client->country->id) ? 'selected' : null }} value="{{ $country->id }}">
|
||||
{{ $country->iso_3166_2 }}
|
||||
({{ $country->name }})
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('country')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4 py-3 bg-gray-50 text-right sm:px-6">
|
||||
<button class="button button-primary">
|
||||
@lang('texts.save')
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@livewire('profile.settings.personal-address', ['countries' => $countries])
|
||||
|
||||
<!-- Client shipping address -->
|
||||
<div class="mt-10 sm:mt-6">
|
||||
|
@ -12,7 +12,6 @@
|
||||
<div class="mt-5 md:mt-0 md:col-span-2">
|
||||
<form wire:submit.prevent="submit" method="POST" id="update_contact">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="shadow overflow-hidden rounded">
|
||||
<div class="px-4 py-5 bg-white sm:p-6">
|
||||
<div class="grid grid-cols-6 gap-6">
|
||||
|
@ -0,0 +1,84 @@
|
||||
<div class="mt-10 sm:mt-6">
|
||||
<div class="md:grid md:grid-cols-3 md:gap-6">
|
||||
<div class="md:col-span-1">
|
||||
<div class="sm:px-0">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900">{{ ctrans('texts.personal_address') }}</h3>
|
||||
<p class="mt-1 text-sm leading-5 text-gray-500">
|
||||
{{ ctrans('texts.enter_your_personal_address') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5 md:mt-0 md:col-span-2">
|
||||
<form wire:submit.prevent="submit" method="POST" id="update_contact">
|
||||
@csrf
|
||||
<div class="px-4 py-5 bg-white sm:p-6">
|
||||
<div class="grid grid-cols-6 gap-6">
|
||||
<div class="col-span-6 sm:col-span-4">
|
||||
<label for="address1" class="input-label">{{ ctrans('texts.address1') }}</label>
|
||||
<input id="address1" class="input w-full" name="address1" wire:model.defer="address1" />
|
||||
@error('address1')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-3">
|
||||
<label for="address2" class="input-label">{{ ctrans('texts.address2') }}</label>
|
||||
<input id="address2" class="input w-full" name="address2" wire:model.defer="address2" />
|
||||
@error('address2')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-3">
|
||||
<label for="city" class="input-label">{{ ctrans('texts.city') }}</label>
|
||||
<input id="city" class="input w-full" name="city" wire:model.defer="city" />
|
||||
@error('city')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-2">
|
||||
<label for="state" class="input-label">{{ ctrans('texts.state') }}</label>
|
||||
<input id="state" class="input w-full" name="state" wire:model.defer="state" />
|
||||
@error('state')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-2">
|
||||
<label for="postal_code" class="input-label">{{ ctrans('texts.postal_code') }}</label>
|
||||
<input id="postal_code" class="input w-full" name="postal_code" wire:model.defer="postal_code" />
|
||||
@error('postal_code')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-span-6 sm:col-span-2">
|
||||
<label for="country" class="input-label">@lang('texts.country')</label>
|
||||
<select id="country" class="input w-full form-select" wire:model.defer="country_id">
|
||||
@foreach($countries as $country)
|
||||
<option value="{{ $country->id }}">
|
||||
{{ $country->iso_3166_2 }} ({{ $country->name }})
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('country')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4 py-3 bg-gray-50 text-right sm:px-6">
|
||||
<button class="button button-primary">{{ $saved }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user