1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 01:11:34 +02:00
invoiceninja/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php

59 lines
1.5 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()->guard('contact')->user()->client,
'name' => auth()->guard('contact')->user()->client->present()->name,
'vat_number' => auth()->guard('contact')->user()->client->present()->vat_number,
'website' => auth()->guard('contact')->user()->client->present()->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'];
$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()]);
}
}