feat: Exibe modal de confirmação ao excluir usuário.
feat: Exibe modal de confirmação ao excluir usuário.
This commit is contained in:
commit
692dd1fba8
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Admin\User;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class DeleteUser extends Component
|
||||||
|
{
|
||||||
|
#[On('confirm-delete')]
|
||||||
|
public function deleteUser($payload)
|
||||||
|
{
|
||||||
|
|
||||||
|
$deletedClient = User::findOrFail($payload);
|
||||||
|
|
||||||
|
if ($deletedClient) {
|
||||||
|
$deletedClient->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatch('user-deleted');
|
||||||
|
$this->dispatch('notify', message: 'Cliente excluído com sucesso!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return '<div></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -34,7 +34,7 @@ class="action-button text-blue-600 hover:text-blue-800 cursor-pointer"
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button @click="$dispatch('confirm-delete-user', { id: '{{ $user->id }}' }); showUsers = false"
|
<button @click="$dispatch('sure', { id: '{{ $user->id }}' }); showUsers = false"
|
||||||
class="action-button text-red-600 hover:text-red-800 cursor-pointer"
|
class="action-button text-red-600 hover:text-red-800 cursor-pointer"
|
||||||
title="Excluir Usuário">
|
title="Excluir Usuário">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue