| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yatra\Database\Tables; |
| 4 |
|
| 5 |
use Yatra\Database\Tables\BaseTable; |
| 6 |
|
| 7 |
/** |
| 8 |
* Trip Itinerary Day Entry Table Class |
| 9 |
* |
| 10 |
* Stores individual entries/activities for each day in a trip itinerary. |
| 11 |
* Each entry represents a specific activity, meal, accommodation, etc. |
| 12 |
* |
| 13 |
* @package Yatra\Database\Tables |
| 14 |
* @since 2.0.0 |
| 15 |
*/ |
| 16 |
class TripItineraryDayEntryTable extends BaseTable |
| 17 |
{ |
| 18 |
/** |
| 19 |
* Table name without prefix |
| 20 |
* |
| 21 |
* @var string The base table name without WordPress prefix |
| 22 |
*/ |
| 23 |
protected static string $table = 'yatra_trip_itinerary_day_entry'; |
| 24 |
|
| 25 |
/** |
| 26 |
* Get the complete table schema as raw SQL CREATE TABLE statement |
| 27 |
* |
| 28 |
* @return string Complete CREATE TABLE SQL statement |
| 29 |
*/ |
| 30 |
public static function getSchema(): string |
| 31 |
{ |
| 32 |
$tableName = static::getTableName(); |
| 33 |
$daysTableName = (new \Yatra\Database\Tables\TripItineraryDaysTable())->getTableName(); |
| 34 |
$charsetCollate = static::getCharsetCollate(); |
| 35 |
|
| 36 |
return <<<SQL |
| 37 |
CREATE TABLE IF NOT EXISTS `{$tableName}` ( |
| 38 |
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 39 |
`day_id` bigint(20) unsigned NOT NULL COMMENT 'Reference to yatra_trip_itinerary_days.id', |
| 40 |
`trip_id` bigint(20) unsigned NOT NULL, |
| 41 |
`title` varchar(255) NOT NULL COMMENT 'Entry title (activity name, meal type, etc.)', |
| 42 |
`description` text DEFAULT NULL COMMENT 'Entry description/details', |
| 43 |
`item_type_id` bigint(20) unsigned DEFAULT NULL COMMENT 'Reference to classification item type', |
| 44 |
`item_id` bigint(20) unsigned DEFAULT NULL COMMENT 'Reference to classification item', |
| 45 |
`item_type` varchar(50) DEFAULT NULL COMMENT 'Item type (activity, meal, accommodation, etc.)', |
| 46 |
`item_name` varchar(255) DEFAULT NULL COMMENT 'Item name from classification', |
| 47 |
`item_icon` varchar(255) DEFAULT NULL COMMENT 'Item icon from classification', |
| 48 |
`time` varchar(50) DEFAULT NULL COMMENT 'Time display (e.g., "9:00 AM - 10:00 AM")', |
| 49 |
`start_time` varchar(20) DEFAULT NULL COMMENT 'Start time (HH:MM format)', |
| 50 |
`end_time` varchar(20) DEFAULT NULL COMMENT 'End time (HH:MM format)', |
| 51 |
`time_type` enum('exact','duration','flexible') DEFAULT 'exact' COMMENT 'Time specification type', |
| 52 |
`location` varchar(255) DEFAULT NULL COMMENT 'Location name', |
| 53 |
`location_latitude` decimal(10,8) DEFAULT NULL COMMENT 'Location latitude coordinate', |
| 54 |
`location_longitude` decimal(11,8) DEFAULT NULL COMMENT 'Location longitude coordinate', |
| 55 |
`duration` varchar(50) DEFAULT NULL COMMENT 'Duration (e.g., "2 hours", "1 day")', |
| 56 |
`cost` decimal(10,2) DEFAULT NULL COMMENT 'Cost amount', |
| 57 |
`cost_per_person` tinyint(1) DEFAULT 0 COMMENT 'Whether cost is per person', |
| 58 |
`notes` text DEFAULT NULL COMMENT 'Additional notes', |
| 59 |
`included_items` longtext DEFAULT NULL COMMENT 'JSON: Array of included items', |
| 60 |
`excluded_items` longtext DEFAULT NULL COMMENT 'JSON: Array of excluded items', |
| 61 |
`gallery` longtext DEFAULT NULL COMMENT 'JSON: Array of gallery images with metadata', |
| 62 |
`video_url` varchar(2048) DEFAULT NULL COMMENT 'Video URL (YouTube, Vimeo, etc.)', |
| 63 |
`status` varchar(20) DEFAULT 'publish' COMMENT 'Entry status (publish, draft, etc.)', |
| 64 |
`order` smallint(5) unsigned DEFAULT 0 COMMENT 'Order within the day', |
| 65 |
`created_at` datetime DEFAULT CURRENT_TIMESTAMP, |
| 66 |
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 67 |
`created_by` bigint(20) unsigned DEFAULT NULL COMMENT 'User ID who created this record', |
| 68 |
`updated_by` bigint(20) unsigned DEFAULT NULL COMMENT 'User ID who last updated this record', |
| 69 |
`metadata` longtext DEFAULT NULL COMMENT 'JSON: Additional metadata for future use', |
| 70 |
PRIMARY KEY (`id`), |
| 71 |
KEY `idx_day_order` (`day_id`, `order`), |
| 72 |
KEY `trip_id` (`trip_id`), |
| 73 |
KEY `item_type_id` (`item_type_id`), |
| 74 |
KEY `item_id` (`item_id`), |
| 75 |
KEY `item_type` (`item_type`), |
| 76 |
KEY `status` (`status`), |
| 77 |
KEY `location_latitude` (`location_latitude`), |
| 78 |
KEY `location_longitude` (`location_longitude`), |
| 79 |
KEY `created_at` (`created_at`), |
| 80 |
KEY `updated_at` (`updated_at`), |
| 81 |
CONSTRAINT `fk_itinerary_day_entry_day_id` FOREIGN KEY (`day_id`) REFERENCES `{$daysTableName}` (`id`) ON DELETE CASCADE |
| 82 |
) ENGINE=InnoDB {$charsetCollate} COMMENT='Trip itinerary day entries - individual activities/items'; |
| 83 |
SQL; |
| 84 |
} |
| 85 |
} |
| 86 |
|