bots = \App\Models\Bot::all(); } public function toggleBot($botId) { $bot = \App\Models\Bot::find($botId); if ($bot) { $bot->enabled = !$bot->enabled; $bot->save(); $this->bots = \App\Models\Bot::all(); // Refresh the list flash()->success("Bot '{$bot->name}' has been " . ($bot->enabled ? 'enabled' : 'disabled') . "."); } } public function deleteBot(int $botId): void { $bot = \App\Models\Bot::find($botId); if ($bot) { LivewireAlert::title('Are you sure you want to delete ' . $bot->name . '?') ->asConfirm() ->onConfirm('confirmDelete', [$bot]) ->show(); } } public function confirmDelete(Bot $bot): void { $bot->delete(); $this->bots = \App\Models\Bot::all(); // Refresh the list flash()->success("Bot '{$bot->name}' has been deleted."); } public function runBot($botId) { $bot = \App\Models\Bot::find($botId); if ($bot) { LivewireAlert::title('Are you sure you want to run ' . $bot->name . '?') ->asConfirm() ->onConfirm('confirmRunBot', [$bot]) ->show(); } } public function confirmRunBot(Bot $bot): void { // Dispatch the job to run the bot $class = new $bot->class($bot->config ?? []); $class->run(); flash()->success("Bot '{$bot->name}' is being executed."); } public function render() { return view('livewire.bots-list'); } }