<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Services\Payroll\PayrollEngine;
use Illuminate\Http\Request;

class PayrollController extends Controller
{
    public function generate(Request $request, PayrollEngine $engine)
    {
        $data = $request->validate(['period' => ['required', 'date_format:Y-m']]);

        return $engine->generate($request->user()->tenant_id, $data['period']);
    }

    public function approve(string $payroll)
    {
        return ['id' => $payroll, 'status' => 'approved'];
    }

    public function lock(string $payroll)
    {
        return ['id' => $payroll, 'status' => 'locked'];
    }
}
