diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index b0b7571..8a93347 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -13,7 +13,6 @@ class ClientController extends Controller public function __construct(ClientService $userService) {} public function dashboard(Request $request): View { - $clients = Client::all(); - return view('dashboard', ['clients' => $clients]); + return view('dashboard'); } } diff --git a/app/Livewire/Admin/AddClient.php b/app/Livewire/Admin/AddClient.php index 2808a57..99f8b74 100644 --- a/app/Livewire/Admin/AddClient.php +++ b/app/Livewire/Admin/AddClient.php @@ -5,6 +5,7 @@ use App\Models\Client; use App\Services\ClientService; use App\Livewire\Forms\ClientForm; // 1. Importa seu Form Object +use Illuminate\Support\Facades\Auth; use Livewire\Component; use Livewire\WithFileUploads; use Illuminate\Support\Facades\Crypt; diff --git a/app/Livewire/Admin/DeleteClient.php b/app/Livewire/Admin/DeleteClient.php new file mode 100644 index 0000000..64b6069 --- /dev/null +++ b/app/Livewire/Admin/DeleteClient.php @@ -0,0 +1,30 @@ +delete(); + } + + $this->dispatch('clientDeleted'); + // (Opcional) Envia uma notificação de sucesso + $this->dispatch('notify', message: 'Cliente excluído com sucesso!'); + } + + public function render() + { + return '
'; + } +} diff --git a/app/Livewire/Admin/ShowClient.php b/app/Livewire/Admin/ShowClient.php new file mode 100644 index 0000000..bc522bb --- /dev/null +++ b/app/Livewire/Admin/ShowClient.php @@ -0,0 +1,23 @@ + $clients + ]); + } +} diff --git a/app/Livewire/Forms/ClientForm.php b/app/Livewire/Forms/ClientForm.php index e6f4801..0f04d91 100644 --- a/app/Livewire/Forms/ClientForm.php +++ b/app/Livewire/Forms/ClientForm.php @@ -8,7 +8,6 @@ class ClientForm extends Form { - // 2. ATRIBUTOS REMOVIDOS: Os #[Rule(...)] foram removidos daqui public $client_name = ''; public $legal_name = ''; public $cnpj = ''; diff --git a/app/Services/ClientService.php b/app/Services/ClientService.php index 4ed0af6..8368323 100644 --- a/app/Services/ClientService.php +++ b/app/Services/ClientService.php @@ -4,6 +4,7 @@ use App\Models\Client; use App\Models\User; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; class ClientService @@ -12,6 +13,10 @@ class ClientService public function __construct(protected Client $client) {} public function addClient(array $client) { + if (!Auth::check()) { + return redirect()->to('/login'); + } + return Client::create($client); } } diff --git a/resources/views/components/are-you-sure.blade.php b/resources/views/components/are-you-sure.blade.php index b6d0c6e..629159c 100644 --- a/resources/views/components/are-you-sure.blade.php +++ b/resources/views/components/are-you-sure.blade.php @@ -3,42 +3,35 @@ - 'showQuestion' controla a visibilidade. - '@sure.window' é o evento que dispara a abertura. --> -
+
-