<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\CreateAkunRequest;
use App\Http\Requests\UpdateAkunRequest;
use App\Services\AkunService;

class AkunController extends Controller
{
    protected $akunService;

    public function __construct(AkunService $akunService)
    {
        $this->akunService = $akunService;
    }

    public function index()
    {
        return $this->akunService->getAll();
    }

    public function create()
    {
        //
    }

    public function store(CreateAkunRequest $request)
    {
        $validated = $request->validated();
        return $this->akunService->createAkun($validated);
    }

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

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

    public function update(UpdateAkunRequest $request, string $id)
    {
        $validated = $request->validated();
        return $this->akunService->updateAkun($id, $validated);
    }

    public function destroy(string $id)
    {
        return $this->akunService->deleteAkun($id);
    }
}
