<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\CreateProdukDepositoRequest;
use App\Http\Requests\UpdateProdukDepositoRequest;
use App\Services\DepositoService;

class ProdukDepositoController extends Controller
{
    protected $depositoService;

    public function __construct(DepositoService $depositoService)
    {
        $this->depositoService = $depositoService;
    }

    public function index()
    {
        return $this->depositoService->getAllProduk();
    }

    public function create()
    {
        //
    }

    public function store(CreateProdukDepositoRequest $request)
    {
        $validated = $request->validated();
        return $this->depositoService->createProduk($validated);
    }

    public function show(string $id)
    {
        return $this->depositoService->findById($id);
    }

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

    public function update(UpdateProdukDepositoRequest $request, string $id)
    {
        $validatedData = $request->validated();
        return $this->depositoService->updateProduk($id, $validatedData);
    }

    public function destroy(string $id)
    {
        return $this->depositoService->deleteProdukDeposito($id);
    }
}
