<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Additional;
use App\Http\Requests\Admin\AdditionalRequest; // Gunakan FormRequest baru

class AdditionalController extends Controller
{
    public function store(AdditionalRequest $request)
    {
        Additional::create($request->validated());
        return redirect()->back()->with('success', 'Additional berhasil ditambahkan!');
    }

    public function update(AdditionalRequest $request, string $id)
    {
        $additional = Additional::findOrFail($id);
        $additional->update($request->validated());
        return redirect()->back()->with('success', 'Additional berhasil diperbarui!');
    }

    public function destroy(string $id)
    {
        $additional = Additional::findOrFail($id);
        $additional->delete();

        return redirect()->back()->with('success', 'Additional berhasil dihapus!');
    }
}
