2020-09-24 13:44:56 +02:00
|
|
|
<?php
|
|
|
|
|
2023-12-13 17:52:49 +01:00
|
|
|
namespace App\Livewire\Profile\Settings;
|
2020-09-24 13:44:56 +02:00
|
|
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class NameWebsiteLogo extends Component
|
|
|
|
{
|
|
|
|
public $profile;
|
|
|
|
|
|
|
|
public $name;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-05-14 10:18:26 +02:00
|
|
|
public $vat_number;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-09-24 13:44:56 +02:00
|
|
|
public $website;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2020-11-27 12:08:39 +01:00
|
|
|
public $phone;
|
2020-09-24 13:44:56 +02:00
|
|
|
|
|
|
|
public $saved;
|
|
|
|
|
|
|
|
public $rules = [
|
2021-01-15 14:07:33 +01:00
|
|
|
'name' => ['sometimes', 'min:3'],
|
2021-05-14 10:18:26 +02:00
|
|
|
'vat_number' => ['sometimes'],
|
2021-01-15 14:07:33 +01:00
|
|
|
'website' => ['sometimes'],
|
|
|
|
'phone' => ['sometimes', 'string', 'max:255'],
|
2020-09-24 13:44:56 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
$this->fill([
|
2022-02-15 23:13:23 +01:00
|
|
|
'profile' => auth()->guard('contact')->user()->client,
|
2022-09-05 05:12:47 +02:00
|
|
|
'name' => auth()->guard('contact')->user()->client->present()->name(),
|
|
|
|
'vat_number' => auth()->guard('contact')->user()->client->vat_number ?: '',
|
|
|
|
'website' => auth()->guard('contact')->user()->client->website,
|
|
|
|
'phone' => auth()->guard('contact')->user()->client->present()->phone(),
|
2020-09-24 13:44:56 +02:00
|
|
|
'saved' => ctrans('texts.save'),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return render('profile.settings.name-website-logo');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
$data = $this->validate($this->rules);
|
|
|
|
|
2020-11-27 12:08:39 +01:00
|
|
|
$this->profile->name = $data['name'];
|
2021-05-14 10:18:26 +02:00
|
|
|
$this->profile->vat_number = $data['vat_number'];
|
2020-11-27 12:08:39 +01:00
|
|
|
$this->profile->website = $data['website'];
|
|
|
|
$this->profile->phone = $data['phone'];
|
|
|
|
|
|
|
|
$this->profile->save();
|
2020-09-24 13:44:56 +02:00
|
|
|
|
|
|
|
$this->saved = ctrans('texts.saved_at', ['time' => now()->toTimeString()]);
|
|
|
|
}
|
|
|
|
}
|