Files
Scheduler/app/Livewire/BotsList.php
2025-08-30 16:11:06 +02:00

33 lines
663 B
PHP

<?php
namespace App\Livewire;
use Livewire\Component;
class BotsList extends Component
{
public $bots;
public function mount()
{
$this->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 render()
{
return view('livewire.bots-list');
}
}