Initial work
This commit is contained in:
32
app/Livewire/BotsList.php
Normal file
32
app/Livewire/BotsList.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user