'boolean', 'filesize' => 'integer', 'sort_order' => 'integer', ]; /** * Relationships */ // Each gallery image belongs to one album public function album() { return $this->belongsTo(Album::class, 'album_id'); } /** * Accessors & Mutators */ // Get full image URL (assuming images are stored in /storage/gallery) public function getImageUrlAttribute(): ?string { return $this->image ? asset('storage/gallery/' . $this->image) : null; } // Dynamic title accessor (returns appropriate language) public function getTitleAttribute(): ?string { $locale = app()->getLocale(); return $locale === 'ar' && $this->title_ar ? $this->title_ar : $this->title_en; } // Dynamic description accessor public function getDescriptionAttribute(): ?string { $locale = app()->getLocale(); return $locale === 'ar' && $this->description_ar ? $this->description_ar : $this->description_en; } /** * Scopes */ // Scope: only visible images public function scopeActive($query) { return $query->where('status', true); } // Scope: order by display order public function scopeOrdered($query) { return $query->orderBy('sort_order', 'asc'); } }