<?php

namespace App\Livewire\FormBuilder;

use Livewire\Component;

class Edit extends Component
{
    public function editData(Request $request)
    {
        return FormBuilder::where('id', $request->id)->first();
    }

    public function update(Request $request)
    {
        $item = FormBuilder::findOrFail($request->id);
        $item->name = $request->name;
        $item->content = $request->form;
        $item->update();
        return response()->json('updated successfully');
    }
    
    public function render()
    {
        return view('livewire.form-builder.edit');
    }
}
