<?php

namespace App\Http\Controllers;

use App\Http\Resources\HabitEntryResource;
use App\Models\HabitEntry;
use Illuminate\Http\Request;

class HabitEntryApiController extends Controller
{
    public function index()
    {
        return HabitEntryResource::collection(HabitEntry::all());
    }

    public function store(Request $request)
    {
        $request->validate([

        ]);

        return new HabitEntryResource(HabitEntry::create($request->validated()));
    }

    public function show(HabitEntry $habitEntry)
    {
        return new HabitEntryResource($habitEntry);
    }

    public function update(Request $request, HabitEntry $habitEntry)
    {
        $request->validate([

        ]);

        $habitEntry->update($request->validated());

        return new HabitEntryResource($habitEntry);
    }

    public function destroy(HabitEntry $habitEntry)
    {
        $habitEntry->delete();

        return response()->json();
    }
}