# STD-01 — Model Scopes & Relationships — Kelengkapan

**Category:** code_standards  
**Generated:** 2026-05-19T21:36:13.928860  

**Target Files:**
- `app/Models/Product.php`
- `app/Models/BlogPost.php`
- `app/Models/Career.php`
- `app/Models/ContactMessage.php`
- `app/Models/SiteSetting.php`

---

Kamu adalah expert Laravel security & UI auditor.
Project: CRIUS COMPRESSOR — Laravel 12, Tailwind CSS, Alpine.js, Bilingual ID/EN.
Stack: PHP 8.3, Laravel 12, MySQL, Tailwind CSS v3, Alpine.js v3.
Design system: CSS variables --navy, --blue-light, --accent, font Montserrat.
Admin layout: resources/views/layouts/admin.blade.php
Frontend layout: resources/views/layouts/app.blade.php
Helpers: setting(), locale_field(), active_locale() di app/Helpers/helpers.php
Bilingual: field _id / _en suffix, middleware SetLocale, URL prefix /en.

ATURAN OUTPUT KAMU:
1. Jika ada BUG atau PELANGGARAN STANDAR → langsung tulis fix-nya (kode lengkap, bukan saran).
2. Format output: [FILE PATH] → [MASALAH] → [FIX CODE].
3. Jika file sudah benar → tulis "✓ OK: [alasan singkat]".
4. JANGAN tambah penjelasan panjang. Langsung ke kode.
5. Prioritas: CRITICAL > HIGH > MEDIUM > LOW.

============================================================
TASK: Audit model scopes, relationships, dan accessors.

STANDAR WAJIB SETIAP MODEL:
1. Scope active(): scopeActive($query) { return $query->where('is_active', true); }
2. Scope ordered(): scopeOrdered($query) { return $query->orderBy('sort_order'); }
3. Semua relasi harus ada dengan return type hint
4. Accessor untuk computed property

CEK Product.php:
1. Apakah ada: scopeActive, scopeOrdered, scopeFeatured?
2. Apakah ada relasi: category(), brand(), images(), specs(), highlights()?
3. Apakah ada accessor getWhatsappLinkAttribute()?
4. Apakah ada accessor getThumbnailUrlAttribute() yang return full URL?
5. Apakah $fillable sudah lengkap sesuai ERD?

CEK BlogPost.php:
1. Apakah ada: scopePublished() { where('status','published')->where('published_at','<=',now()) }?
2. Apakah ada: scopeFeatured()?
3. Apakah ada relasi: category(), author(), tags()?
4. Apakah ada accessor getExcerptAttribute() yang fallback ke substr content?

CEK Career.php:
1. Apakah ada scopeActive() yang juga cek expired_at > now()?
   where('is_active',true)->where(fn($q) => $q->whereNull('expired_at')->orWhere('expired_at','>',now()))
2. Apakah ada relasi applications()?

CEK ContactMessage.php:
1. Apakah ada scopeUnread()?
2. Apakah ada method markAsRead()?

Tulis fix lengkap untuk setiap model yang kurang.
