feat: Inclui o método updateClient e utilização do service par realizar as ações.

This commit is contained in:
LukiBeg 2025-11-17 17:22:02 -03:00
parent 7fce28174e
commit 4fdc598aca
1 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,8 @@
namespace App\Livewire\Forms; namespace App\Livewire\Forms;
use App\Services\ClientService;
use Exception;
use Livewire\Attributes\Validate; use Livewire\Attributes\Validate;
use Livewire\Form; use Livewire\Form;
use App\Models\Client; use App\Models\Client;
@ -24,6 +26,7 @@ class ClientForm extends Form
public $modules = ''; public $modules = '';
public $whatsapp_number = ''; public $whatsapp_number = '';
public $whatsapp_activation_date; public $whatsapp_activation_date;
public ClientService $clientService;
// Método para preencher o formulário (para edição futura) // Método para preencher o formulário (para edição futura)
public function addClient(Client $client) public function addClient(Client $client)
@ -32,10 +35,19 @@ public function addClient(Client $client)
$data['has_call_center'] = (bool) $client->has_call_center; $data['has_call_center'] = (bool) $client->has_call_center;
$data['has_voice_gateway'] = (bool) $client->has_voice_gateway; $data['has_voice_gateway'] = (bool) $client->has_voice_gateway;
$data['has_fop2'] = (bool) $client->has_fop2; $data['has_fop2'] = (bool) $client->has_fop2;
$data['client_name'] = $data['name'];
$this->fill($data); $this->fill($data);
} }
public function updateClient(Client $client)
{
if(!$this->clientService->updateClient($client)){
throw new Exception('Ocorreu um erro.');
}
}
// 4. ADICIONADO: Método de Regras // 4. ADICIONADO: Método de Regras
/** /**
* Define as regras de validação para o formulário. * Define as regras de validação para o formulário.