Permission Requirements
Gallery management requires the
access.admin.panel permission. All routes are protected by authentication, email verification, and permission checks.Gallery Routes
All gallery routes are nested under/admin/gallery:
Photo Management
Manage individual photos at/admin/gallery/photos.
Viewing Photos
The photo index displays all photos with media attachments:Uploading Photos
Upload photos using the Livewire upload component.Upload Photo Livewire Component
TheUploadPhoto component handles file uploads:
Photo Validation
Upload Limits
- File type: Images only
- Max size: 20MB (20,480 KB)
- Accepted formats: JPEG, PNG, GIF, WebP
Editing Photos
Update photo details at/admin/gallery/photos/{photo}/edit.
Deleting Photos
Delete photos with automatic cleanup of media files and album relationships.Managing Unassigned Photos
TheManagephoto Livewire component shows photos not in any album:
Album Management
Organize photos into albums at/admin/gallery/albums.
Viewing Albums
Albums are displayed with photo counts and cover images:Creating Albums
Create albums using the Livewire album manager.Manage Album Livewire Component
Album Validation Rules
Album Requirements
- Name: Required, 3-255 characters
- Description: Optional, max 1000 characters
- Category: Optional, max 255 characters
- Cover image: Optional, max 1MB
Album Slug Generation
Albums automatically generate URL-friendly slugs:Deleting Albums
Album deletion removes all associations and media:Photo Model
The Photo model uses Spatie Media Library:Photo Features
- Media Collection: Photos stored in
imagescollection - Preview Generation: Automatic 300x300 preview thumbnails
- Album Association: Many-to-many relationship with albums
Album Model
The Album model with media support:Album Features
- Slug-based URLs: Albums use slugs for clean URLs
- Cover Image: Optional album cover in
album_covercollection - Photo Count: Eager load photo counts for performance
- Preview Generation: 300x300 previews for cover images
Media Library Integration
Spatie Media Library
LaraCMS uses Spatie Media Library for file management:- Collections: Organize media by type (images, album_cover)
- Conversions: Automatic thumbnail generation
- Storage: Files stored in public disk
- Database: Media metadata in
mediatable
Media Collections
| Collection | Used By | Purpose |
|---|---|---|
images | Photos | Full-size photo storage |
album_cover | Albums | Album cover images |
Image Conversions
Both photos and albums generate preview conversions:Photo-Album Relationships
Photos and albums use a many-to-many relationship:Database Structure
- Pivot Table:
album_photo - Foreign Keys:
photo_id,album_id - Association: One photo can belong to multiple albums
Managing Associations
Best Practices
Image Optimization
Image Optimization
Optimize images before upload:
- Resize large images (recommended max: 3000px)
- Compress for web (80-90% quality)
- Use appropriate formats (JPEG for photos, PNG for graphics)
- Remove EXIF data if privacy is a concern
Album Organization
Album Organization
Organize albums effectively:
- Use descriptive album names
- Group related photos together
- Add descriptions for context
- Use categories for better organization
- Set meaningful cover images
Storage Management
Storage Management
Keep storage clean:
- Delete unused photos regularly
- Monitor disk space usage
- Run
php artisan media-library:cleanto remove orphaned files - Configure automatic cleanup if needed
Performance
Performance
Optimize gallery performance:
- Use pagination for large galleries
- Eager load relationships (
with('media')) - Generate thumbnails for grid views
- Consider CDN for public galleries
Troubleshooting
Upload Failures
Upload Failures
Common upload issues:
- File too large: Increase PHP
upload_max_filesizeandpost_max_size - Permission denied: Check storage directory permissions (775/755)
- Invalid file type: Only images are accepted
- Timeout: Large files may need increased
max_execution_time
Missing Images
Missing Images
If images don’t display:
- Verify storage link:
php artisan storage:link - Check file permissions
- Verify
publicdisk configuration inconfig/filesystems.php - Clear cache:
php artisan cache:clear
Thumbnail Generation
Thumbnail Generation
If thumbnails aren’t generating:
- Check GD or Imagick extension is installed
- Verify sufficient memory:
memory_limitin php.ini - Check queue is running if using queued conversions
- Run conversions manually:
php artisan media-library:regenerate
Frontend Gallery Display
Photos and albums are displayed on the frontend:Next Steps
Blog Management
Learn about managing blog content
User Management
Control who can manage the gallery