slug)) { $this->slug = Str::slug($this->name); } else { $this->slug = Str::slug($this->slug); } $this->validate([ 'name' => 'required|string|max:100', 'slug' => 'required|string|unique:chatbots,slug|max:100', ]); $chatbot = Chatbot::create([ 'name' => $this->name, 'slug' => $this->slug, ]); $this->name = ''; $this->slug = ''; $this->statusMessage = "Le chatbot '{$chatbot->name}' a été créé avec succès !"; $this->statusType = 'success'; } public function deleteChatbot(int $id, WeaviateService $weaviateService) { $chatbot = Chatbot::find($id); if ($chatbot) { $name = $chatbot->name; // Delete data in Weaviate for this chatbot $weaviateService->clearChatbotData((string) $chatbot->id); // Delete database records $chatbot->delete(); $this->statusMessage = "Le chatbot '{$name}' et toutes ses données vectorielles ont été supprimés."; $this->statusType = 'success'; } } public function render() { $chatbots = Chatbot::latest()->get(); return view('livewire.chatbot-manager', compact('chatbots')); } }