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


This documentation was automatically generated from Git commit data.