JezK
Edit File: Gallery.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class Gallery extends Model { protected $fillable = [ 'title', 'description', 'type', 'gallery_category_id', 'image_path', 'youtube_url', 'is_active', 'is_featured', ]; protected function casts(): array { return [ 'is_active' => 'boolean', 'is_featured' => 'boolean', ]; } public function getImageUrlAttribute(): ?string { if ($this->image_path) { if (str_starts_with($this->image_path, 'http://') || str_starts_with($this->image_path, 'https://')) { return $this->image_path; } return asset('storage/' . $this->image_path); } return null; } public function scopeActive($query) { return $query->where('is_active', true); } public function galleryCategory(): BelongsTo { return $this->belongsTo(GalleryCategory::class, 'gallery_category_id'); } }