Files
bogazici-api/app/Http/Controllers/Api/V1/SettingController.php
2026-03-27 10:41:54 +03:00

53 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Controllers\Api\V1;
use App\Enums\SettingGroup;
use App\Http\Controllers\Controller;
use App\Repositories\Contracts\SettingRepositoryInterface;
use Illuminate\Http\JsonResponse;
use OpenApi\Attributes as OA;
class SettingController extends Controller
{
public function __construct(private SettingRepositoryInterface $repository) {}
/**
* Return all public settings grouped by group name.
*/
#[OA\Get(
path: '/api/v1/settings',
summary: 'Tüm site ayarlarını getir (group bazlı nested)',
tags: ['Settings'],
responses: [new OA\Response(response: 200, description: 'Ayarlar listesi')],
)]
public function index(): JsonResponse
{
return response()->json($this->repository->publicGrouped());
}
/**
* Return public settings for a single group.
*/
#[OA\Get(
path: '/api/v1/settings/{group}',
summary: 'Tek grup ayarlarını getir',
tags: ['Settings'],
parameters: [new OA\Parameter(name: 'group', in: 'path', required: true, schema: new OA\Schema(type: 'string'))],
responses: [
new OA\Response(response: 200, description: 'Grup ayarları'),
new OA\Response(response: 404, description: 'Grup bulunamadı'),
],
)]
public function show(string $group): JsonResponse
{
$settingGroup = SettingGroup::tryFrom($group);
if (! $settingGroup) {
abort(404, 'Ayar grubu bulunamadı.');
}
return response()->json($this->repository->publicByGroup($settingGroup));
}
}