<?php

namespace App\Livewire;

use Livewire\Component;
use App\Models\BufferCustomer;
use App\Models\ControlLog;
use App\Models\Lamp;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;

class LampTable extends DataTableComponent
{
    public function builder(): Builder
    {
        return ControlLog::query()
            ->orderBy('updated_at', 'asc');
    }


    public function configure(): void
    {
        $this->setPrimaryKey('id');
        $this->setPerPageAccepted([5, 10, 25, 50, 100]); // rappasoft hanya boleh 10, 25, 50, jadi wajib set ini!
        $this->setPerPage(5); // set agar default 5!
        $this->setPerPageVisibilityStatus(false); // ini untuk set perpage berapa list bagi admin (ui)
        $this->setColumnSelectStatus(false);
    }

    public function columns(): array
    {
        return [
            // Column::make('#')
            //     ->label(fn ($row, $index) => $index + 1),
            Column::make('Status', 'action')
                ->sortable(),
             Column::make('Trigered', 'triggered_by')
                ->sortable(),
          
            Column::make("Waktu", "updated_at")
                ->sortable(),
        ];
    }
}
