<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Kriteria;
use App\Http\Requests\KriteriaRequest;
use App\Http\Requests\UpdateKriteriaRequest;
use Illuminate\Support\Facades\Session;

class PerbandinganKriteriaController extends Controller
{
    //
    public function kriteria(){
        $kriterias = Kriteria::all();
        return view('admin.kriteria.kriteria', compact('kriterias'));
    }
    public function editkriteria(Kriteria $kriteria){
        return view('admin.kriteria.editkriteria', compact('kriteria'));
    }
    public function tambahkriteria(){
        return view('admin.kriteria.tambahkriteria');
    }
    public function storekriteria(KriteriaRequest $request){
        $validatedData = $request->validated();
        Kriteria::create($validatedData);
        return redirect()->route('kriteria');
    }
    public function updatekriteria(UpdateKriteriaRequest $request, Kriteria $kriteria){
        $validatedData = $request->validated();
        $kriteria->update($validatedData);
        return redirect()->route('kriteria');
    }
    public function deletekriteria(Kriteria $kriteria) {
        $kriteria->delete();
        return redirect()->route('kriteria')->with('success', 'user deleted successfully');
    }




    

}
