PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / app / Database / Tables / EnquiriesTable.php

EnquiriesTable.php in Yatra – Travel Booking & Tour Operator Software trunk, at app/Database/Tables/EnquiriesTable.php

77 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yatra\Database\Tables;
4
5 /**
6 * Enquiries Table Class
7 *
8 * Represents the customer enquiries table (wp_yatra_enquiries) containing
9 * customer inquiry data including contact information, message content,
10 * travel preferences, response tracking, and status management.
11 *
12 * This table follows the new simplified pattern with only two static methods:
13 * - getTableName(): Returns the prefixed table name
14 * - getSchema(): Returns the complete CREATE TABLE SQL statement
15 *
16 * Usage:
17 * EnquiriesTable::getTableName() // Returns 'wp_yatra_enquiries'
18 * EnquiriesTable::getSchema() // Returns complete SQL schema
19 *
20 * @package Yatra\Database\Tables
21 * @since 1.0.0
22 */
23 class EnquiriesTable extends BaseTable
24 {
25 /**
26 * Table name without prefix
27 *
28 * @var string The base table name without WordPress prefix
29 */
30 protected static string $table = 'yatra_enquiries';
31
32 /**
33 * Get the complete table schema as raw SQL CREATE TABLE statement
34 *
35 * Returns the full SQL schema for the enquiries table using heredoc syntax
36 * for proper IDE syntax highlighting. Includes all columns, indexes,
37 * and constraints from the original Database.php schema.
38 *
39 * @return string Complete CREATE TABLE SQL statement
40 */
41 public static function getSchema(): string
42 {
43 $tableName = static::getTableName();
44 $charsetCollate = static::getCharsetCollate();
45
46 return <<<SQL
47 CREATE TABLE IF NOT EXISTS `{$tableName}` (
48 `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
49 `trip_id` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'Related trip ID',
50 `name` varchar(255) NOT NULL COMMENT 'Customer full name',
51 `email` varchar(255) NOT NULL COMMENT 'Customer email',
52 `phone` varchar(50) DEFAULT NULL COMMENT 'Customer phone',
53 `message` text NOT NULL COMMENT 'Enquiry message',
54 `travel_date` date DEFAULT NULL COMMENT 'Preferred travel date',
55 `metadata` longtext DEFAULT NULL COMMENT 'JSON metadata (e.g., traveler classifications: [{\"id\":1,\"title\":\"Adult\",\"count\":2}])',
56 `travelers_count` smallint(5) UNSIGNED DEFAULT NULL COMMENT 'Total travelers derived from metadata classifications',
57 `status` varchar(50) DEFAULT 'new',
58 `response_notes` text DEFAULT NULL COMMENT 'Internal response notes',
59 `responded_at` datetime DEFAULT NULL COMMENT 'When enquiry was responded to',
60 `responded_by` bigint(20) UNSIGNED DEFAULT NULL COMMENT 'User who responded',
61 `ip_address` varchar(45) DEFAULT NULL COMMENT 'Customer IP address',
62 `user_agent` varchar(500) DEFAULT NULL COMMENT 'Customer browser info',
63 `source` varchar(50) DEFAULT 'website' COMMENT 'Source of enquiry',
64 `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
65 `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
66 `created_by` bigint(20) unsigned DEFAULT NULL COMMENT 'User ID who created this enquiry record',
67
68 PRIMARY KEY (`id`),
69 KEY `idx_trip_status` (`trip_id`, `status`),
70 KEY `idx_email` (`email`),
71 KEY `idx_status` (`status`),
72 KEY `idx_created_at` (`created_at`)
73 ) {$charsetCollate} COMMENT='Customer enquiries';
74 SQL;
75 }
76 }
77