# Admin Panel — Eğitim Blokları (Course Blocks) ## Genel Bakış Eğitim detay sayfalarında artık **Page Builder** mantığı var. Her eğitimin altına sıralı bloklar eklenebilir. Yapı, Page Blocks ile birebir aynı — aynı blok tipleri, aynı `_width` desteği, aynı content JSON formatı. --- ## API Endpoints Tüm endpoint'ler `auth:sanctum` ile korunuyor. Base URL: `{API_URL}/api/admin` | Method | Endpoint | Açıklama | |--------|----------|----------| | `GET` | `/admin/courses/{course}/blocks` | Eğitimin bloklarını listele | | `POST` | `/admin/courses/{course}/blocks` | Yeni blok oluştur | | `GET` | `/admin/courses/{course}/blocks/{block}` | Blok detayı | | `PUT` | `/admin/courses/{course}/blocks/{block}` | Blok güncelle | | `DELETE` | `/admin/courses/{course}/blocks/{block}` | Blok sil | | `POST` | `/admin/courses/{course}/blocks/reorder` | Sıralama güncelle | --- ## GET /admin/courses/{course}/blocks ```json { "data": [ { "id": 1, "type": "hero", "content": { "title": "Köprüüstü Kaynak Yönetimi", "subtitle": "BRM", "description": "STCW uyumlu ileri düzey eğitim..." }, "order_index": 0 }, { "id": 2, "type": "text", "content": { "_width": "half", "title": "Eğitim Kapsamı", "body": "" }, "order_index": 1 } ] } ``` --- ## POST /admin/courses/{course}/blocks — Yeni Blok ### Request: ```json { "type": "hero", "content": { "title": "Blok başlığı", "description": "Açıklama..." }, "order_index": 0, "is_active": true } ``` ### Response (201): ```json { "id": 5, "type": "hero", "content": { "title": "Blok başlığı", "description": "Açıklama..." }, "order_index": 0 } ``` ### Validation Kuralları: | Alan | Kural | |------|-------| | `type` | required, string, max:50 | | `content` | present, array (boş obje `{}` gönderilebilir) | | `order_index` | optional, integer, min:0 (gönderilmezse otomatik son sıraya eklenir) | | `is_active` | optional, boolean | --- ## PUT /admin/courses/{course}/blocks/{block} — Güncelle Sadece değişen alanları gönder: ```json { "content": { "_width": "half", "title": "Güncel Başlık", "body": "

Yeni içerik

" } } ``` --- ## DELETE /admin/courses/{course}/blocks/{block} ```json { "message": "Blok silindi." } ``` --- ## POST /admin/courses/{course}/blocks/reorder — Sıralama ```json { "items": [ { "id": 3, "order_index": 0 }, { "id": 1, "order_index": 1 }, { "id": 2, "order_index": 2 } ] } ``` ```json { "message": "Blok sıralaması güncellendi." } ``` --- ## Blok Tipleri Page Blocks ile aynı blok tipleri kullanılır: | type | Açıklama | Örnek Kullanım | |------|----------|----------------| | `hero` | Üst banner/başlık alanı | Eğitim hero bölümü | | `text` | Zengin metin bloğu | Eğitim kapsamı, açıklama | | `text_image` | Metin + görsel yan yana | Eğitim tanıtımı | | `cards` | Kart grid | Özellikler, sertifikalar | | `stats_grid` | İstatistik/adım kartları | Süre, katılımcı, başarı oranı | | `cta` | Call-to-action | Kayıt ol butonu | | `faq` | Sıkça sorulan sorular | Eğitimle ilgili SSS | | `gallery` | Görsel galeri | Eğitim ortamı fotoğrafları | | `video` | Video embed | Tanıtım videosu | | `testimonials` | Yorumlar/referanslar | Mezun görüşleri | | `html` | Serbest HTML | Özel içerik | --- ## `_width` Desteği `content` JSON içinde `_width` key'i blok genişliğini belirler: | Değer | Açıklama | |-------|----------| | `"full"` | Tam genişlik (varsayılan — key gönderilmezse otomatik full) | | `"half"` | Yarım genişlik — ardışık iki half blok yan yana render edilir | ```json // Yan yana iki blok { "type": "text", "content": { "_width": "half", "title": "Sol", "body": "..." }, "order_index": 0 } { "type": "stats_grid", "content": { "_width": "half", "title": "Sağ", ... }, "order_index": 1 } ``` --- ## Public API — Frontend `GET /api/v1/courses/{slug}` artık `blocks` array'ini de döner: ```json { "data": { "id": 1, "slug": "kopruustu-kaynak-yonetimi", "title": "Köprüüstü Kaynak Yönetimi (BRM)", "category": { ... }, "blocks": [ { "id": 1, "type": "hero", "content": { ... }, "order_index": 0 }, { "id": 2, "type": "text", "content": { "_width": "half", ... }, "order_index": 1 }, { "id": 3, "type": "stats_grid", "content": { "_width": "half", ... }, "order_index": 2 } ], "schedules": [ ... ], ... } } ``` Frontend, sayfa blokları ile aynı `BlockRenderer` bileşenini kullanabilir. --- ## Admin Panel Entegrasyonu ### Önerilen UI: Eğitim düzenleme sayfasında (`/admin/courses/{id}/edit`) mevcut form alanlarının altına bir **"Bloklar"** sekmesi/bölümü ekle. Bu bölüm Page Builder ile aynı mantıkta çalışır: 1. Blok listesi `order_index` sıralı gösterilir 2. Sürükle-bırak ile sıralama → `POST .../reorder` 3. "Blok Ekle" butonu → tip seçimi → `POST .../blocks` 4. Blok düzenleme → inline edit veya modal → `PUT .../blocks/{id}` 5. Blok silme → onay dialog → `DELETE .../blocks/{id}` ### Aynı bileşenleri paylaşabilirsin: Page Blocks için yazdığın `BlockEditor`, `BlockTypeSelector`, `ContentEditor` bileşenlerini **doğrudan** course blocks için de kullan. Sadece API endpoint prefix'i değişir: - Page: `/admin/pages/{id}/blocks` - Course: `/admin/courses/{id}/blocks`