feat: Inclui o método updateClient e utilização do service par realizar as ações.
This commit is contained in:
parent
7fce28174e
commit
4fdc598aca
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Livewire\Forms;
|
||||
|
||||
use App\Services\ClientService;
|
||||
use Exception;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Form;
|
||||
use App\Models\Client;
|
||||
|
|
@ -24,6 +26,7 @@ class ClientForm extends Form
|
|||
public $modules = '';
|
||||
public $whatsapp_number = '';
|
||||
public $whatsapp_activation_date;
|
||||
public ClientService $clientService;
|
||||
|
||||
// Método para preencher o formulário (para edição futura)
|
||||
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_voice_gateway'] = (bool) $client->has_voice_gateway;
|
||||
$data['has_fop2'] = (bool) $client->has_fop2;
|
||||
$data['client_name'] = $data['name'];
|
||||
|
||||
$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
|
||||
/**
|
||||
* Define as regras de validação para o formulário.
|
||||
|
|
|
|||
Loading…
Reference in New Issue