Files
hoshpoint-backend/app/Http/Controllers/Api/CategoryController.php
soheil khaledabadi ae974c2afa feat: add ApiResponse trait for standardized API responses
chore: update composer dependencies to include phppresentation

chore: update composer.lock after adding phppresentation

feat: create categories migration for category management

feat: create templates migration for template storage

feat: create template generations migration for tracking template usage

feat: create template keys migration for template customization

feat: create notifications migration for user notifications

feat: update API routes for categories, templates, and user profile management

docs: update API documentation to include new endpoints for profile and wallet
2026-07-07 01:03:12 +03:30

53 lines
1.7 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Resources\CategoryResource;
use App\Models\Category;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
use OpenApi\Attributes as OA;
class CategoryController extends Controller
{
use ApiResponse;
#[OA\Get(
path: '/categories',
description: 'List active template categories',
summary: 'List categories',
tags: ['Templates'],
responses: [
new OA\Response(
response: 200,
description: 'Categories fetched successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'message', type: 'string', example: 'دسته‌بندی‌ها با موفقیت دریافت شد.'),
new OA\Property(
property: 'data',
properties: [
new OA\Property(
property: 'categories',
type: 'array',
items: new OA\Items(ref: '#/components/schemas/Category')
),
],
type: 'object'
),
]
)
),
]
)]
public function index(): JsonResponse
{
$categories = Category::query()->where('is_active', true)->orderBy('name')->get();
return $this->success('دسته‌بندی‌ها با موفقیت دریافت شد.', [
'categories' => CategoryResource::collection($categories),
]);
}
}