Product Templates
ProductTemplate defines what a trip IS - its route, structure, and identity. Content is written in a source locale and can be translated when creating market-specific versions.
Purpose
Section titled “Purpose”- Define trip itinerary (cities, nights per stop)
- Store base marketing content
- Calculate trip duration automatically
- Provide foundation for market-specific products
Data Model
Section titled “Data Model”Table: product_templates
| Field | Type | Purpose |
|---|---|---|
| title | varchar | Product name |
| subtitle | varchar | Marketing tagline |
| sku | varchar | Auto-generated: <ID>-<DAYS> |
| source_locale | varchar | Content language (e.g., en_US) |
| itinerary | jsonb | Array of stops with city, nights, details |
| duration | int | Trip length in days (auto-calculated) |
| highlights | jsonb | Key selling points |
| categories | jsonb | Product categories (beach, luxury, etc.) |
Source: backend/app/Models/ProductTemplate.php
Itinerary Structure
Section titled “Itinerary Structure”[ { "city": "Beijing", "nights": 2, "title": "Arrival & Forbidden City", "details": "Explore the historic heart of China...", "day_image": "path/to/image.jpg" }, { "city": "Xi'an", "nights": 2, "title": "Terracotta Warriors", "details": "Visit the legendary army..." }]Cities and nights define the trip structure. Airports are NOT stored here - they are configured at the ProductByMarket level.
Duration Calculation
Section titled “Duration Calculation”Duration is automatically calculated from itinerary:
duration = total_nights + 1Example: 2 nights Beijing + 2 nights Xi’an = 4 nights + 1 = 5 days
Route Helpers
Section titled “Route Helpers”$template->getRouteSummary(); // "Beijing -> Xi'an -> Shanghai"$template->getTotalNights(); // 6$template->isMultiStop(); // true if > 2 stops$template->getItineraryCities(); // ["Beijing", "Xi'an", "Shanghai"]$template->getItineraryWithDayOffsets(); // Adds day_offset to each stopSource: backend/app/Models/ProductTemplate.php:183-248
AI Content Generation
Section titled “AI Content Generation”Templates support AI-powered content generation:
- Trip Parser - Paste raw trip info, AI generates all fields
- Title-based Generation - Enter title, AI generates descriptions
Configuration: OPENROUTER_API_KEY environment variable
Source: backend/app/Services/ProductTemplateAIService.php
Business Rules
Section titled “Business Rules”- SKU is auto-generated on save (cannot be manually edited)
- Duration auto-calculates from itinerary nights
- Templates with associated ProductByMarket records are “locked”
- Itinerary changes propagate to market products
Related
Section titled “Related”- Products by Market - Market-specific configuration
- Admin Panel - Filament management
- Database Relationships - Entity diagram and FK references