Implement Gallery Model as Second Collection Type (#212)
Commit: 7c6644cd034e8db0bbdcf987683e044a811d76b6
Date: 2025-07-09 19:59:30 +0200
Author: PascalHavelange
Commit Message
Implement Gallery Model as Second Collection Type (#212)
* # feat: Implement Gallery model with polymorphic content support
## Overview
Implement the Gallery model as the second type of collection according to the requirements in temp_INSTRUCTIONS.md. Galleries can contain any combination of Items and Details, providing flexible content organization for museum collections.
## Features Added
### 🗄️ Database Structure
- **Gallery Model**: Main gallery entity with UUID primary key and unique internal_name
- **GalleryTranslation Model**: Translation support with title, description, and optional URL
- **GalleryPartner Pivot**: Many-to-many relationships with partners using PartnerLevel enum
- **Galleryable Pivot**: Polymorphic many-to-many relationships with Items and Details
### 🔗 Relationships
- Galleries ↔ Items (many-to-many via galleryables table)
- Galleries ↔ Details (many-to-many via galleryables table)
- Galleries ↔ Partners (many-to-many with contribution levels)
- Galleries ↔ Translations (one-to-many with language/context support)
### 📊 Key Capabilities
- **Mixed Content**: Galleries can contain both Items and Details in any combination
- **Ordering**: Content can be ordered within galleries using the `order` field
- **Translation Support**: Full multilingual and contextual translation support
- **Partner Relationships**: Three levels of partner contributions (partner, associated_partner, minor_contributor)
- **Laravel 12 Compliance**: Follows all Laravel best practices and conventions
### 🛠️ API Endpoints
- `GET /api/gallery` - List galleries with relationships and computed attributes
- `POST /api/gallery` - Create new gallery with validation
- `GET /api/gallery/{id}` - Show specific gallery with full relationships
- `PUT /api/gallery/{id}` - Update gallery with proper validation
- `DELETE /api/gallery/{id}` - Delete gallery with cascade handling
### ✅ Testing
- **Unit Tests**: 8 tests covering factory functionality and model relationships (32 assertions)
- **Feature Tests**: 48 tests covering complete API functionality (266 assertions)
- Anonymous access protection
- CRUD operations with validation
- Relationship management
- Error handling
### 🔧 Technical Implementation
- Uses UUID primary keys consistent with existing models
- Polymorphic many-to-many relationships for flexible content management
- Proper foreign key constraints and cascade deletion
- Resource transformers for consistent API responses
- Comprehensive validation with Laravel Form Requests
- Seeder integration for database population
## Breaking Changes
None - this is a new feature addition that doesn't modify existing functionality.
## Database Migrations
- `create_galleries_table` - Main gallery storage
- `create_gallery_translations_table` - Translation data
- `create_gallery_partner_table` - Gallery-partner relationships
- `create_galleryables_table` - Polymorphic content relationships
## Dependencies
- Existing Item and Detail models (adds reverse relationships)
- PartnerLevel enum for contribution level management
- Language and Context models for translation support
All tests passing ✅
API client updated to v1.1.7-dev.709.1921 ✅
* # feat: Implement Gallery model with polymorphic content support
## Overview
Implement the Gallery model as the second type of collection according to the requirements in temp_INSTRUCTIONS.md. Galleries can contain any combination of Items and Details, providing flexible content organization for museum collections.
## Features Added
### 🗄️ Database Structure
- **Gallery Model**: Main gallery entity with UUID primary key and unique internal_name
- **GalleryTranslation Model**: Translation support with title, description, and optional URL
- **GalleryPartner Pivot**: Many-to-many relationships with partners using PartnerLevel enum
- **Galleryable Pivot**: Polymorphic many-to-many relationships with Items and Details
### 🔗 Relationships
- Galleries ↔ Items (many-to-many via galleryables table)
- Galleries ↔ Details (many-to-many via galleryables table)
- Galleries ↔ Partners (many-to-many with contribution levels)
- Galleries ↔ Translations (one-to-many with language/context support)
### 📊 Key Capabilities
- **Mixed Content**: Galleries can contain both Items and Details in any combination
- **Ordering**: Content can be ordered within galleries using the `order` field
- **Translation Support**: Full multilingual and contextual translation support
- **Partner Relationships**: Three levels of partner contributions (partner, associated_partner, minor_contributor)
- **Laravel 12 Compliance**: Follows all Laravel best practices and conventions
### 🛠️ API Endpoints
- `GET /api/gallery` - List galleries with relationships and computed attributes
- `POST /api/gallery` - Create new gallery with validation
- `GET /api/gallery/{id}` - Show specific gallery with full relationships
- `PUT /api/gallery/{id}` - Update gallery with proper validation
- `DELETE /api/gallery/{id}` - Delete gallery with cascade handling
### ✅ Testing
- **Unit Tests**: 8 tests covering factory functionality and model relationships (32 assertions)
- **Feature Tests**: 48 tests covering complete API functionality (266 assertions)
- Anonymous access protection
- CRUD operations with validation
- Relationship management
- Error handling
### 🔧 Technical Implementation
- Uses UUID primary keys consistent with existing models
- Polymorphic many-to-many relationships for flexible content management
- Proper foreign key constraints and cascade deletion
- Resource transformers for consistent API responses
- Comprehensive validation with Laravel Form Requests
- Seeder integration for database population
## Breaking Changes
None - this is a new feature addition that doesn't modify existing functionality.
## Database Migrations
- `create_galleries_table` - Main gallery storage
- `create_gallery_translations_table` - Translation data
- `create_gallery_partner_table` - Gallery-partner relationships
- `create_galleryables_table` - Polymorphic content relationships
## Dependencies
- Existing Item and Detail models (adds reverse relationships)
- PartnerLevel enum for contribution level management
- Language and Context models for translation support
All tests passing ✅
API client updated to v1.1.7-dev.709.1921 ✅
* # Update documentation for Gallery model implementation
## Documentation Updates
- Updated README.md to include Gallery model description and API endpoints
- Enhanced docs/api-models.md with comprehensive Gallery documentation
- Added Gallery model description with polymorphic relationships
- Documented translation support and partner relationships
- Updated data relationships diagram to include Gallery connections
- Updated CHANGELOG.md to document Gallery implementation features
## API Client Update
- Notes that the TypeScript API client was updated to version @metanull/inventory-app-api-client@1.1.7-dev.709.1921
- Client documentation will be automatically generated during next OpenAPI documentation update
Refs: Gallery model implementation documentation
---------
Co-authored-by: Pascal HAVELANGE <havelangep@hotmail.com>
Files Changed
- 📝 Modified:
CHANGELOG.md
- 📝 Modified:
README.md
- 📝 Modified:
api-client/.openapi-generator/FILES
- 📝 Modified:
api-client/api.ts
- ✅ Added:
api-client/docs/GalleryApi.md
- ✅ Added:
api-client/docs/GalleryIndex200Response.md
- ✅ Added:
api-client/docs/GalleryResource.md
- ✅ Added:
api-client/docs/GalleryStore200Response.md
- ✅ Added:
api-client/docs/GalleryStoreRequest.md
- ✅ Added:
api-client/docs/GalleryTranslationResource.md
- ✅ Added:
api-client/docs/GalleryUpdateRequest.md
- 📝 Modified:
api-client/package.json
- ✅ Added:
app/Http/Controllers/GalleryController.php
- ✅ Added:
app/Http/Resources/GalleryResource.php
- ✅ Added:
app/Http/Resources/GalleryTranslationResource.php
- 📝 Modified:
app/Models/Detail.php
- ✅ Added:
app/Models/Gallery.php
- ✅ Added:
app/Models/GalleryPartner.php
- ✅ Added:
app/Models/GalleryTranslation.php
- ✅ Added:
app/Models/Galleryable.php
- 📝 Modified:
app/Models/Item.php
- ✅ Added:
database/factories/GalleryFactory.php
- ✅ Added:
database/factories/GalleryTranslationFactory.php
- ✅ Added:
database/migrations/2025_07_09_155503_create_galleries_table.php
- ✅ Added:
database/migrations/2025_07_09_155546_create_gallery_translations_table.php
- ✅ Added:
database/migrations/2025_07_09_155650_create_gallery_partner_table.php
- ✅ Added:
database/migrations/2025_07_09_155809_create_galleryables_table.php
- 📝 Modified:
database/seeders/DatabaseSeeder.php
- ✅ Added:
database/seeders/GallerySeeder.php
- 📝 Modified:
docs/_openapi/api.json
- 📝 Modified:
docs/api-client/addressapi.md
- 📝 Modified:
docs/api-client/addressindex200response.md
- 📝 Modified:
docs/api-client/addressresource.md
- 📝 Modified:
docs/api-client/addressstore201response.md
- 📝 Modified:
docs/api-client/addressstore422response.md
- 📝 Modified:
docs/api-client/addressstorerequest.md
- 📝 Modified:
docs/api-client/addressstorerequesttranslationsinner.md
- 📝 Modified:
docs/api-client/addresstranslationapi.md
- 📝 Modified:
docs/api-client/addresstranslationindex200response.md
- 📝 Modified:
docs/api-client/addresstranslationresource.md
- 📝 Modified:
docs/api-client/addresstranslationstore200response.md
- 📝 Modified:
docs/api-client/addresstranslationstorerequest.md
- 📝 Modified:
docs/api-client/addresstranslationupdaterequest.md
- 📝 Modified:
docs/api-client/addressupdaterequest.md
- 📝 Modified:
docs/api-client/addressupdaterequesttranslationsinner.md
- 📝 Modified:
docs/api-client/artistresource.md
- 📝 Modified:
docs/api-client/authorresource.md
- 📝 Modified:
docs/api-client/availableimageapi.md
- 📝 Modified:
docs/api-client/availableimageindex200response.md
- 📝 Modified:
docs/api-client/availableimageresource.md
- 📝 Modified:
docs/api-client/availableimageshow200response.md
- 📝 Modified:
docs/api-client/availableimageupdaterequest.md
- 📝 Modified:
docs/api-client/collectionapi.md
- 📝 Modified:
docs/api-client/collectionindex200response.md
- 📝 Modified:
docs/api-client/collectionresource.md
- 📝 Modified:
docs/api-client/collectionstore200response.md
- 📝 Modified:
docs/api-client/collectionstorerequest.md
- 📝 Modified:
docs/api-client/collectiontranslationresource.md
- 📝 Modified:
docs/api-client/collectionupdaterequest.md
- 📝 Modified:
docs/api-client/contactapi.md
- 📝 Modified:
docs/api-client/contactindex200response.md
- 📝 Modified:
docs/api-client/contactresource.md
- 📝 Modified:
docs/api-client/contactstore201response.md
- 📝 Modified:
docs/api-client/contactstorerequest.md
- 📝 Modified:
docs/api-client/contactstorerequesttranslationsinner.md
- 📝 Modified:
docs/api-client/contacttranslationapi.md
- 📝 Modified:
docs/api-client/contacttranslationindex200response.md
- 📝 Modified:
docs/api-client/contacttranslationresource.md
- 📝 Modified:
docs/api-client/contacttranslationstore200response.md
- 📝 Modified:
docs/api-client/contacttranslationstorerequest.md
- 📝 Modified:
docs/api-client/contacttranslationupdaterequest.md
- 📝 Modified:
docs/api-client/contactupdaterequest.md
- 📝 Modified:
docs/api-client/contactupdaterequesttranslationsinner.md
- 📝 Modified:
docs/api-client/contextapi.md
- 📝 Modified:
docs/api-client/contextgetdefault404response.md
- 📝 Modified:
docs/api-client/contextindex200response.md
- 📝 Modified:
docs/api-client/contextresource.md
- 📝 Modified:
docs/api-client/contextsetdefault200response.md
- 📝 Modified:
docs/api-client/contextsetdefaultrequest.md
- 📝 Modified:
docs/api-client/contextstorerequest.md
- 📝 Modified:
docs/api-client/countryapi.md
- 📝 Modified:
docs/api-client/countryindex200response.md
- 📝 Modified:
docs/api-client/countryresource.md
- 📝 Modified:
docs/api-client/countrystore200response.md
- 📝 Modified:
docs/api-client/countrystorerequest.md
- 📝 Modified:
docs/api-client/countryupdaterequest.md
- 📝 Modified:
docs/api-client/detailapi.md
- 📝 Modified:
docs/api-client/detailindex200response.md
- 📝 Modified:
docs/api-client/detailresource.md
- 📝 Modified:
docs/api-client/detailstore200response.md
- 📝 Modified:
docs/api-client/detailstorerequest.md
- 📝 Modified:
docs/api-client/detailtranslationapi.md
- 📝 Modified:
docs/api-client/detailtranslationresource.md
- 📝 Modified:
docs/api-client/detailtranslationsapi.md
- 📝 Modified:
docs/api-client/detailtranslationshow200response.md
- 📝 Modified:
docs/api-client/detailtranslationstorerequest.md
- 📝 Modified:
docs/api-client/detailtranslationupdaterequest.md
- 📝 Modified:
docs/api-client/imageuploadapi.md
- 📝 Modified:
docs/api-client/imageuploadindex200response.md
- 📝 Modified:
docs/api-client/imageuploadresource.md
- 📝 Modified:
docs/api-client/imageuploadstatus200response.md
- 📝 Modified:
docs/api-client/imageuploadstatus200responseanyof.md
- 📝 Modified:
docs/api-client/imageuploadstatus200responseanyof1.md
- 📝 Modified:
docs/api-client/imageuploadstatus404response.md
- 📝 Modified:
docs/api-client/imageuploadstore200response.md
- 📝 Modified:
docs/api-client/index.md
- 📝 Modified:
docs/api-client/inlineobject.md
- 📝 Modified:
docs/api-client/inlineobject1.md
- 📝 Modified:
docs/api-client/itemapi.md
- 📝 Modified:
docs/api-client/itemindex200response.md
- 📝 Modified:
docs/api-client/itemresource.md
- 📝 Modified:
docs/api-client/itemstore200response.md
- 📝 Modified:
docs/api-client/itemstorerequest.md
- 📝 Modified:
docs/api-client/itemtranslationapi.md
- 📝 Modified:
docs/api-client/itemtranslationresource.md
- 📝 Modified:
docs/api-client/itemtranslationsapi.md
- 📝 Modified:
docs/api-client/itemtranslationshow200response.md
- 📝 Modified:
docs/api-client/itemtranslationstorerequest.md
- 📝 Modified:
docs/api-client/itemtranslationupdaterequest.md
- 📝 Modified:
docs/api-client/itemupdatetagsrequest.md
- 📝 Modified:
docs/api-client/itemwithalltagsrequest.md
- 📝 Modified:
docs/api-client/languageapi.md
- 📝 Modified:
docs/api-client/languagegetdefault404response.md
- 📝 Modified:
docs/api-client/languagegetenglish404response.md
- 📝 Modified:
docs/api-client/languageindex200response.md
- 📝 Modified:
docs/api-client/languageresource.md
- 📝 Modified:
docs/api-client/languagesetdefault200response.md
- 📝 Modified:
docs/api-client/languagestorerequest.md
- 📝 Modified:
docs/api-client/languageupdaterequest.md
- 📝 Modified:
docs/api-client/locationapi.md
- 📝 Modified:
docs/api-client/locationindex200response.md
- 📝 Modified:
docs/api-client/locationresource.md
- 📝 Modified:
docs/api-client/locationstore201response.md
- 📝 Modified:
docs/api-client/locationstorerequest.md
- 📝 Modified:
docs/api-client/locationstorerequesttranslationsinner.md
- 📝 Modified:
docs/api-client/locationtranslationapi.md
- 📝 Modified:
docs/api-client/locationtranslationindex200response.md
- 📝 Modified:
docs/api-client/locationtranslationresource.md
- 📝 Modified:
docs/api-client/locationtranslationstore200response.md
- 📝 Modified:
docs/api-client/locationtranslationstorerequest.md
- 📝 Modified:
docs/api-client/locationtranslationupdaterequest.md
- 📝 Modified:
docs/api-client/locationupdaterequest.md
- 📝 Modified:
docs/api-client/locationupdaterequesttranslationsinner.md
- 📝 Modified:
docs/api-client/markdownapi.md
- 📝 Modified:
docs/api-client/markdownapiendpointsformarkdownprocessingandconversionapi.md
- 📝 Modified:
docs/api-client/markdownfromhtmlrequest.md
- 📝 Modified:
docs/api-client/markdownismarkdownrequest.md
- 📝 Modified:
docs/api-client/markdownpreview200response.md
- 📝 Modified:
docs/api-client/markdownpreview200responsedata.md
- 📝 Modified:
docs/api-client/markdownpreview422response.md
- 📝 Modified:
docs/api-client/markdownpreview500response.md
- 📝 Modified:
docs/api-client/markdowntohtmlrequest.md
- 📝 Modified:
docs/api-client/mobileappauthenticationapi.md
- 📝 Modified:
docs/api-client/partnerapi.md
- 📝 Modified:
docs/api-client/partnerindex200response.md
- 📝 Modified:
docs/api-client/partnerresource.md
- 📝 Modified:
docs/api-client/partnerstore200response.md
- 📝 Modified:
docs/api-client/partnerstorerequest.md
- 📝 Modified:
docs/api-client/pictureapi.md
- 📝 Modified:
docs/api-client/picturedetachfromitem422response.md
- 📝 Modified:
docs/api-client/pictureindex200response.md
- 📝 Modified:
docs/api-client/pictureresource.md
- 📝 Modified:
docs/api-client/pictureshow200response.md
- 📝 Modified:
docs/api-client/picturetranslationapi.md
- 📝 Modified:
docs/api-client/picturetranslationindex200response.md
- 📝 Modified:
docs/api-client/picturetranslationindex200responselinks.md
- 📝 Modified:
docs/api-client/picturetranslationindex200responsemeta.md
- 📝 Modified:
docs/api-client/picturetranslationindex200responsemetalinksinner.md
- 📝 Modified:
docs/api-client/picturetranslationresource.md
- 📝 Modified:
docs/api-client/picturetranslationstore200response.md
- 📝 Modified:
docs/api-client/picturetranslationstorerequest.md
- 📝 Modified:
docs/api-client/picturetranslationupdaterequest.md
- 📝 Modified:
docs/api-client/pictureupdaterequest.md
- 📝 Modified:
docs/api-client/projectapi.md
- 📝 Modified:
docs/api-client/projectenabled200response.md
- 📝 Modified:
docs/api-client/projectresource.md
- 📝 Modified:
docs/api-client/projectsetenabledrequest.md
- 📝 Modified:
docs/api-client/projectsetlaunched200response.md
- 📝 Modified:
docs/api-client/projectsetlaunchedrequest.md
- 📝 Modified:
docs/api-client/projectstorerequest.md
- 📝 Modified:
docs/api-client/provinceapi.md
- 📝 Modified:
docs/api-client/provinceindex200response.md
- 📝 Modified:
docs/api-client/provinceresource.md
- 📝 Modified:
docs/api-client/provincestore201response.md
- 📝 Modified:
docs/api-client/provincetranslationapi.md
- 📝 Modified:
docs/api-client/provincetranslationindex200response.md
- 📝 Modified:
docs/api-client/provincetranslationresource.md
- 📝 Modified:
docs/api-client/provincetranslationstore200response.md
- 📝 Modified:
docs/api-client/provincetranslationstorerequest.md
- 📝 Modified:
docs/api-client/provincetranslationupdaterequest.md
- 📝 Modified:
docs/api-client/tagapi.md
- 📝 Modified:
docs/api-client/tagindex200response.md
- 📝 Modified:
docs/api-client/tagresource.md
- 📝 Modified:
docs/api-client/tagstore200response.md
- 📝 Modified:
docs/api-client/tagstorerequest.md
- 📝 Modified:
docs/api-client/tokenacquirerequest.md
- 📝 Modified:
docs/api-client/workshopresource.md
- 📝 Modified:
docs/api-models.md
- 📝 Modified:
routes/api.php
- ✅ Added:
tests/Feature/Api/Gallery/AnonymousTest.php
- ✅ Added:
tests/Feature/Api/Gallery/DestroyTest.php
- ✅ Added:
tests/Feature/Api/Gallery/IndexTest.php
- ✅ Added:
tests/Feature/Api/Gallery/ShowTest.php
- ✅ Added:
tests/Feature/Api/Gallery/StoreTest.php
- ✅ Added:
tests/Feature/Api/Gallery/UpdateTest.php
- ✅ Added:
tests/Unit/Gallery/FactoryTest.php
Links
This documentation was automatically generated from Git commit data.