Proje: Okul Platform · Hub: Okul Platform — Conventions

JsonResponse Sınıfı

app/Http/Responses/JsonResponse.php — Özel response helper.

Success Response

JsonResponse::success(
    data: $resource,
    status: 200,
    message: null,        // null ise __('messages.http.success')
    additional: ['access_token' => '...']
)

Standart response:

{
    "data": {...},
    "message": "Başarılı."
}

Paginated response: LengthAwarePaginator veya AnonymousResourceCollection (paginator içeren) otomatik algılanır, pagination meta eklenir.

Resources Yapısı

app/Http/Resources/ — Laravel API Resources

Admin/     — Admin panel resource'ları
Customer/  — B2B portal resource'ları
General/   — Genel public resource'lar
User/      — Kullanıcı resource'ları
GenericResource.php    — Genel kaynak
MediaResource.php      — Medya resource
SchoolCommentResource.php
SpecResource.php       — Spec/teknik resource

StringBool Cast

Veritabanında ‘1’/‘0’ string olarak saklanan boolean değerler için custom cast:

  • StringBool'1'true, '0'false
  • StringBoolNullable — Nullable versiyonu

StringEnumType enum’ı ile uyumlu çalışır.

DarkaOnline L5 Swagger

darkaonline/l5-swagger — OpenAPI/Swagger belgelendirme
Controller’larda #[OA\Post(...)], #[OA\Get(...)] attribute’ları
Swagger UI: muhtemelen /api/documentation

Kullanım örneği AuthController’da:

#[OA\Post(
    path: '/auth/login',
    tags: ['Authentication'],
    responses: [
        new SWR\OkResponse(...),
        new SWR\UnauthorizedResponse(),
        ...
    ],
)]

Validation Hata Formatı

Route bazlı validation (AppServiceProvider’da açıklandı): lang/{locale}/{route}.php → özel hata mesajları