<?php

namespace App\Http\Controllers;

use App\Models\Category;
use Illuminate\Http\Request;

class CategoryController extends Controller
{
    public function index()
    {
        $categories = Category::all();
        return view("admin.kategori.index", compact("categories"));
    }

    public function store(Request $request)
    {
        Category::create([
            "nama_kategori" => $request->nama_kategori,
        ]);
        return redirect(
            '/kategori'
        );
    }

    public function delete($id){
        Category::find($id)->delete();
        return redirect(
            '/kategori'
        );
    }
}
