<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\TransaksiDepositoRequest;
use App\Services\TransaksiDepositoService;
use Carbon\Carbon;
use Illuminate\Http\Request;

class TransaksiDepositoController extends Controller
{
    protected $transaksiDepositoService;

    public function __construct(TransaksiDepositoService $transaksiDepositoService)
    {
        $this->transaksiDepositoService = $transaksiDepositoService;
    }

    public function index(Request $request)
    {
        $tgl_awal = $request->input('tgl_awal', Carbon::now());
        $tgl_akhir = $request->input('tgl_akhir', Carbon::now());

        return $this->transaksiDepositoService->getAllTransaksi($tgl_awal, $tgl_akhir);
    }

    public function create()
    {
        //
    }

    public function store(TransaksiDepositoRequest $request)
    {
        $validated = $request->validated();
        return $this->transaksiDepositoService->createTransaksi($validated);
    }

    public function show(string $id)
    {
        //
    }

    public function edit(string $id)
    {
        //
    }

    public function update(Request $request, string $id)
    {
        return $this->transaksiDepositoService->validasiTransaksi($id);
    }

    public function destroy(string $id)
    {
        return $this->transaksiDepositoService->deleteTransaksi($id);
    }
}
