update deploy
This commit is contained in:
52
app/Http/Controllers/Api/V1/SettingController.php
Normal file
52
app/Http/Controllers/Api/V1/SettingController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user