add ability to edit client's phone

This commit is contained in:
Benjamin Beganović 2020-11-27 12:08:39 +01:00
parent 07e1e822f8
commit 2618a1d3b8
2 changed files with 17 additions and 3 deletions

View File

@ -10,12 +10,14 @@ class NameWebsiteLogo extends Component
public $name;
public $website;
public $phone;
public $saved;
public $rules = [
'name' => ['required', 'min:3'],
'website' => ['required', 'url'],
'phone' => ['required', 'string', 'max:255'],
];
public function mount()
@ -24,6 +26,7 @@ class NameWebsiteLogo extends Component
'profile' => auth()->user('contact')->client,
'name' => auth()->user('contact')->client->present()->name,
'website' => auth()->user('contact')->client->present()->website,
'phone' => auth()->user('contact')->client->present()->phone,
'saved' => ctrans('texts.save'),
]);
}
@ -37,9 +40,11 @@ class NameWebsiteLogo extends Component
{
$data = $this->validate($this->rules);
$this->profile
->fill($data)
->save();
$this->profile->name = $data['name'];
$this->profile->website = $data['website'];
$this->profile->phone = $data['phone'];
$this->profile->save();
$this->saved = ctrans('texts.saved_at', ['time' => now()->toTimeString()]);
}

View File

@ -24,6 +24,15 @@
</div>
@enderror
</div>
<div class="col-span-6 sm:col-span-3">
<label for="street" class="input-label">{{ ctrans('texts.phone') }}</label>
<input id="phone" class="input w-full {{ in_array('phone', (array) session('missing_required_fields')) ? 'border border-red-400' : '' }}" name="phone" wire:model.defer="phone" />
@error('phone')
<div class="validation validation-fail">
{{ $message }}
</div>
@enderror
</div>
<div class="col-span-6 sm:col-span-3">
<label for="website" class="input-label">{{ ctrans('texts.website') }}</label>
<input id="website" class="input w-full" name="website" wire:model.defer="website" />