feat: Salva edições sem upar imagens.

feat: Salva edições sem upar imagens.
This commit is contained in:
lukidev 2025-12-09 13:19:45 -03:00 committed by GitHub
commit ee74cd3ccb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -41,12 +41,19 @@ public function edit(ClientService $clientService)
$this->authorize('editClient', Auth::user());
$data = $this->clientForm->validate();
if ($this->clientForm->profile_image_path !== null) {
if ($this->clientForm->profile_image_path) {
$path = $this->clientForm->profile_image_path->store('client_logos', 'public');
$data['profile_image_path'] = $path;
} else {
unset($data['profile_image_path']);
}
$data['root_password'] = Crypt::encryptString($data['root_password']);
if (!empty($data['root_password'])) {
$data['root_password'] = Crypt::encryptString($data['root_password']);
} else {
unset($data['root_password']);
}
if (!$clientService->updateClient($this->client, $data)) {
throw new Exception('O serviço não confirmou a atualização.');

View File

@ -12,7 +12,7 @@ class ClientForm extends Form
public $client_name = '';
public $legal_name = '';
public $cnpj = '';
public $profile_image_path;
public $profile_image_path = null;
public $pbx_hosting = '';
public $activation_date;
public $carrier = '';
@ -35,7 +35,7 @@ public function addClient(Client $client)
$data['has_voice_gateway'] = (bool) $client->has_voice_gateway;
$data['has_fop2'] = (bool) $client->has_fop2;
$data['client_name'] = $data['name'];
$data['whatsapp_activation_date'] = $client->whatsapp_activation_date;
unset($data['profile_image_path']);
$this->fill($data);
}