<?php

namespace App\Http\Controllers\Audit;

use App\Http\Controllers\ApiController;
use App\Http\Requests\Audit\AuditLogFilterRequest;
use App\Http\Resources\Audit\AuditLogResource;
use App\Services\Audit\AuditLogService;

class AuditLogController extends ApiController
{
    protected $service;

    public function __construct(AuditLogService $service)
    {
        $this->service = $service;
    }

    public function index(AuditLogFilterRequest $request)
    {
        $data = $this->service->list(
            $request->validated()
        );

        return $this->successPaginated(
            $data,
            AuditLogResource::class,
            'Data audit log berhasil diambil'
        );
    }

    public function show($id)
    {
        $data = $this->service->detail($id);

        return $this->success(
            new AuditLogResource($data),
            'Detail audit log berhasil diambil'
        );
    }
}
