1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2020-09-24 13:44:56 +02:00
<?php
namespace App\Http\Livewire\Profile\Settings;
use Livewire\Component;
class NameWebsiteLogo extends Component
{
public $profile;
public $name;
public $vat_number;
2020-09-24 13:44:56 +02:00
public $website;
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'],
'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([
'profile' => auth()->user('contact')->client,
'name' => auth()->user('contact')->client->present()->name,
'vat_number' => auth()->user('contact')->client->present()->vat_number,
2020-09-24 13:44:56 +02:00
'website' => auth()->user('contact')->client->present()->website,
2020-11-27 12:08:39 +01:00
'phone' => auth()->user('contact')->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'];
$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()]);
}
}