<?php

namespace App\Http\Controllers;

use App\SettingCredit;
use Illuminate\Http\Request;

class SettingCreditController extends Controller
{
    public function index()
    {
        $credit_setting = SettingCredit::latest()->first();
        return response()->json($credit_setting, 201);
    }

    public function show(SettingCredit $credit)
    {
        return $credit;
    }

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

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

    public function update(Request $request)
    {
        $credit_setting = SettingCredit::latest()->first();
        $credit_setting->update($request->all());

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

    public function delete(SettingCredit $credit)
    {
        $credit->delete();

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