<?php

namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Http\Requests\SocialMedia\CreateSocialMediaRequest;
use App\Http\Requests\SocialMedia\UpdateSocialMediaRequest;
use App\Http\Resources\SocialMedia\SocialMediaResource;
use App\Services\SocialMediaService;

class SocialMediaController extends Controller
{
    public function __construct(private SocialMediaService $service)
    {
        
    }

    public function getAll()
    {
        $data = $this->service->getAll();
        $response = SocialMediaResource::collection($data);
        return response()->json($response);
    }

    public function create(CreateSocialMediaRequest $request)
    {
        $data = $this->service->create($request->validated());
        return response()->json($data);
    }

    public function update(UpdateSocialMediaRequest $request)
    {
        $data = $this->service->updateSocialMedia($request->id, $request->validated());
        return response()->json($data);
    }

    public function delete($id)
    {
        $data = $this->service->delete($id);
        return response()->json($data);
    }
}