Panduan Theming — GoldenStreet Property

Multi-template L1/L2/L3 · Progressive override · White-label

1. Konsep

Resolve view:  themes/{active}/...  →  fallback  →  core/...
Resolve token: themes/{active}/theme.css  →  override  →  app.css default

Tema hanya menyediakan file yang ingin diubah, sisanya fallback ke core.

2. Level Tema

LevelIsiRebuild?
L1theme.json + theme.css (CSS variables)Tidak
L2L1 + override partial/layoutTidak (kecuali JS)
L3L1 + override penuh (layout, home, property, JS)Ya (npm run build)

3. Struktur Folder

resources/views/themes/{slug}/
  theme.json
  theme.css
  layouts/app.blade.php          (L2+)
  partials/navbar.blade.php      (L2+)
  home.blade.php                 (L3)
  property/index.blade.php       (L3)
  property/show.blade.php        (L3)
  assets/js/theme.js             (L3)
public/themes/{slug}/            (hasil build L3)

4. theme.json

{
  "name": "Minimal",
  "slug": "minimal",
  "version": "1.0.0",
  "level": "L1",
  "author": "Anda",
  "description": "Minimalis, token-only",
  "preview": "preview.png",
  "tokens": {
    "colors": { "primary": "#0F172A", "accent": "#10B981" },
    "fonts": { "sans": "Inter", "heading": "Playfair Display" },
    "radius": "0rem"
  },
  "overrides": ["theme.css"],
  "requires_build": false,
  "compatible_core": ">=2.0"
}

5. theme.css

:root {
  --color-primary: 15 23 42;
  --color-accent: 16 185 129;
  --font-sans: 'Inter', sans-serif;
  --font-heading: 'Playfair Display', serif;
  --radius: 0rem;
  --container: 90rem;
}

6. Contoh: Buat Tema L1 Baru (10 menit)

  1. Copy resources/views/themes/default/ → resources/views/themes/saya/.
  2. Edit theme.json → "name": "Saya", "slug": "saya".
  3. Edit theme.css → ganti :root variables.
  4. Login admin → /admin/tema → aktifkan Saya.
  5. Selesai — tanpa rebuild.
Ganti warna/font/radius = cukup ubah theme.css. Tidak perlu build ulang.

7. Laravel 13 — Queue & Cache

7.1 Queue Attributes

Jika tema memicu job/notification, gunakan PHP Attributes:

use Illuminate\Queue\Attributes\{Queue, Tries, Timeout};
use Illuminate\Contracts\Queue\ShouldQueue;

#[Queue('theme-notifications')]
#[Tries(3)]
#[Timeout(60)]
class SendThemeNotification implements ShouldQueue
{
    // ...
}
Jangan campur property legacy (public $tries) dengan attributes — pilih salah satu.

7.2 Cache Serialization

Jika tema meng-cache model/collection, tambahkan di config/cache.php:

'serializable_classes' => [
    Illuminate\Database\Eloquent\Collection::class,
    App\Models\Property::class,
],

Tanpa ini, Cache::remember() yang mengembalikan model akan rusak (__PHP_Incomplete_Class).

8. Kontrak Data

Variabel yang dijamin tersedia di view:

9. Build Aset L3

npm run build
# hasil ke public/build/ dan public/themes/{slug}/

Hanya tema L3 (requires_build: true) yang perlu build ulang.