<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Form;
use App\Lib\FormProcessor;
use Illuminate\Http\Request;

class KybController extends Controller
{
    public function setting()
    {
        $pageTitle = 'KYB Setting';
        $form = Form::where('act','kyb')->first();
        return view('admin.kyb.setting',compact('pageTitle','form'));
    }

    public function settingUpdate(Request $request)
    {
        $formProcessor = new FormProcessor();
        $generatorValidation = $formProcessor->generatorValidation();
        $request->validate($generatorValidation['rules'],$generatorValidation['messages']);
        $exist = Form::where('act','kyb')->first();
        $formProcessor->generate('kyb',$exist,'act');

        $notify[] = ['success','KYB data updated successfully'];
        return back()->withNotify($notify);
    }
}
