feat: Deleta clientes.
This commit is contained in:
parent
6abd11dce7
commit
5451f5c9ab
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\On;
|
||||
use App\Models\Client;
|
||||
|
||||
class DeleteClient extends Component
|
||||
{
|
||||
#[On('confirm-delete')]
|
||||
public function deleteClient($payload)
|
||||
{
|
||||
|
||||
$deletedClient = Client::findOrFail($payload);
|
||||
|
||||
if ($deletedClient) {
|
||||
$deletedClient->delete();
|
||||
}
|
||||
|
||||
$this->dispatch('clientDeleted');
|
||||
// (Opcional) Envia uma notificação de sucesso
|
||||
$this->dispatch('notify', message: 'Cliente excluído com sucesso!');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return '<div></div>';
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue