<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\SettingActiveBank;

class SettingActiveBankController extends Controller
{
    public function index()
    {
        $active_bank_setting = SettingActiveBank::latest()->first();
        return response()->json($active_bank_setting, 200);
    }

    public function update(Request $request)
    {
        $active_bank_setting = SettingActiveBank::latest()->first();

        if(!$active_bank_setting){
            $active_bank_setting = new SettingActiveBank();
        }
        $active_bank_setting->x1_bank_id = $request->input('x1_bank_id');
        $active_bank_setting->x2_bank_id = $request->input('x2_bank_id');
        $active_bank_setting->beneficiary_id = $request->input('beneficiary_id');

        $active_bank_setting->save();

        return response()->json($active_bank_setting, 200);
    }
}
