<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Comment;
use App\Models\Post;
use App\Models\Reply;
use App\Services\LikeService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class LikeController extends Controller
{
    public function __construct(private LikeService $likeService) {}

    public function likePost(Request $request, Post $post): JsonResponse
    {
        $result = $this->likeService->toggle($request->user(), $post);
        return response()->json($result);
    }

    public function likeComment(Request $request, Comment $comment): JsonResponse
    {
        $result = $this->likeService->toggle($request->user(), $comment);
        return response()->json($result);
    }

    public function likeReply(Request $request, Reply $reply): JsonResponse
    {
        $result = $this->likeService->toggle($request->user(), $reply);
        return response()->json($result);
    }
}
