'boolean', 'urutan' => 'integer' ]; /** * Relationship ke Kontrakan */ public function kontrakan() { return $this->belongsTo(Kontrakan::class, 'item_id'); } /** * Relationship ke Laundry */ public function laundry() { return $this->belongsTo(Laundry::class, 'item_id'); } /** * Helper untuk get full path foto */ public function getFotoUrlAttribute() { return asset('uploads/galeri/' . $this->type . '/' . $this->foto); } /** * Scope untuk query galeri by type & item */ public function scopeForItem($query, $type, $itemId) { return $query->where('type', $type) ->where('item_id', $itemId) ->orderBy('urutan'); } /** * Scope untuk ambil foto primary */ public function scopePrimary($query) { return $query->where('is_primary', true); } }