<?php

namespace App\Http\Controllers;

use App\Rate;
use Illuminate\Http\Request;

class RateController extends Controller
{
    public function index()
    {
        return Rate::all();
    }

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

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

    public function update(Request $request, Rate $rate)
    {
        $rate->update($request->all());

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

    public function delete(Rate $rate)
    {
        $rate->delete();

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

    public function show()
    {
        $rate = Rate::latest()->first();

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