<?php

namespace App\Http\Controllers\api\v1\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\BlogCategory\CreateBlogCategoryRequest;
use App\Http\Requests\Admin\BlogCategory\UpdateBlogCategoryRequest;
use App\Service\Admin\BlogCategoryService;
use App\Traits\JsonResponseTrait;
use Illuminate\Http\Request;

class BlogCategoryController extends Controller
{
    use JsonResponseTrait;
    
    public function __construct(protected BlogCategoryService $blogCategoryService)
    {
    }

    /**
     * Get all blog categories
     */
    public function index()
    {
        return $this->blogCategoryService->getAllCategories();
    }

    /**
     * Get blog category by ID
     */
    public function show(string $category_id)
    {
        return $this->blogCategoryService->getCategoryById($category_id);
    }

    /**
     * Create new blog category
     */
    public function store(CreateBlogCategoryRequest $request)
    {
        $input = $request->validated();
        return $this->blogCategoryService->createCategory($input);
    }

    /**
     * Update blog category
     */
    public function update(UpdateBlogCategoryRequest $request, string $category_id)
    {
        $input = $request->validated();
        return $this->blogCategoryService->updateCategory($category_id, $input);
    }

    /**
     * Delete blog category
     */
    public function destroy(string $category_id)
    {
        return $this->blogCategoryService->deleteCategory($category_id);
    }

    /**
     * Toggle category status
     */
    public function toggleStatus(string $category_id)
    {
        return $this->blogCategoryService->toggleCategoryStatus($category_id);
    }
}
