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

33 lines
1016 B
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 Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Cache;
use OpenApi\Attributes as OA;
class PreviewController extends Controller
{
#[OA\Get(
path: '/api/v1/preview/{token}',
summary: 'Önizleme verisini getir (public)',
tags: ['Preview'],
parameters: [new OA\Parameter(name: 'token', in: 'path', required: true, schema: new OA\Schema(type: 'string'))],
responses: [
new OA\Response(response: 200, description: 'Önizleme verisi'),
new OA\Response(response: 404, description: 'Önizleme bulunamadı veya süresi dolmuş'),
],
)]
public function show(string $token): JsonResponse
{
$data = Cache::get("preview_{$token}");
if (! $data) {
return response()->json(['message' => 'Önizleme bulunamadı veya süresi dolmuş.'], 404);
}
return response()->json(['data' => $data]);
}
}