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

36 lines
1.1 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\Http\Controllers\Controller;
use App\Http\Resources\PageResource;
use App\Repositories\Contracts\PageRepositoryInterface;
use Illuminate\Http\JsonResponse;
use OpenApi\Attributes as OA;
class PageController extends Controller
{
public function __construct(private PageRepositoryInterface $repository) {}
#[OA\Get(
path: '/api/v1/pages/{slug}',
summary: 'Sayfa detayı',
tags: ['Pages'],
parameters: [new OA\Parameter(name: 'slug', in: 'path', required: true, schema: new OA\Schema(type: 'string'))],
responses: [
new OA\Response(response: 200, description: 'Sayfa detayı'),
new OA\Response(response: 404, description: 'Sayfa bulunamadı'),
],
)]
public function show(string $slug): JsonResponse
{
$page = $this->repository->findBySlug($slug);
if (! $page || ! $page->is_active) {
return response()->json(['message' => 'Sayfa bulunamadı.'], 404);
}
return response()->json(new PageResource($page));
}
}