<?php

namespace App\Http\Controllers;

use App\SettingBeneficiary;
use Illuminate\Http\Request;

class SettingBeneficiaryController extends Controller
{
    public function index()
    {
        return SettingBeneficiary::all();
    }

    public function show($beneficiary)
    {
        if ($beneficiary == 0){
            response()->json(["company_name"=>"123", "account_number"=>"123"] , 201);
        }
        $beneficiary = SettingBeneficiary::find($beneficiary);
        return $beneficiary;
    }

    public function store(Request $request)
    {
        $beneficiary = SettingBeneficiary::create($request->all());

        return response()->json($beneficiary, 201);
    }

    public function update(Request $request, SettingBeneficiary $beneficiary)
    {
        $beneficiary->update($request->all());

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

    public function delete(SettingBeneficiary $beneficiary)
    {
        $beneficiary->delete();

        return response()->json(null, 204);
    }
}