<?php

namespace App\Http\Controllers;

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

class ChoiceController extends Controller
{
    public function new(Request $request)
    {
        $data = Choice::create([
            'node_id' => $request->node_id,
            'label' => $request->label,
            'text' => $request->text,
            'next_node_id' => $request->next_node_id,
            'status' => $request->status,
            'score' => $request->score,
        ]);
        return redirect()->back()->with('success', 'Data berhasil ditambahkan!');
    }

    public function update(Request $request, $id)
    {
        $data = Choice::find($id);
        $data->update([
            $request->kolom => $request->value
        ]);
        return redirect()->back()->with('success', 'Data berhasil diupdate!');
    }
}
