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 / ReviewsTable.php

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

74 lines 2.5 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 * Reviews Table Class
7 *
8 * Represents the reviews table (wp_yatra_reviews) containing trip review data
9 * including ratings, content, author information, status management,
10 * and helpful voting.
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 * ReviewsTable::getTableName() // Returns 'wp_yatra_reviews'
18 * ReviewsTable::getSchema() // Returns complete SQL schema
19 *
20 * @package Yatra\Database\Tables
21 * @since 1.0.0
22 */
23 class ReviewsTable 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_reviews';
31
32 /**
33 * Get the complete table schema as raw SQL CREATE TABLE statement
34 *
35 * Returns the full SQL schema for the reviews 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 NOT NULL,
50 `user_id` bigint(20) UNSIGNED DEFAULT 0,
51 `rating` tinyint(1) UNSIGNED NOT NULL,
52 `title` varchar(255) DEFAULT NULL,
53 `content` text NOT NULL,
54 `author_name` varchar(100) NOT NULL,
55 `author_email` varchar(100) DEFAULT NULL,
56 `author_location` varchar(100) DEFAULT NULL,
57 `status` enum('pending','approved','rejected','spam','trash') DEFAULT 'pending',
58 `helpful_count` int(11) UNSIGNED DEFAULT 0,
59 `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
60 `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
61 `created_by` bigint(20) unsigned DEFAULT NULL COMMENT 'User ID who created this review',
62 `updated_by` bigint(20) unsigned DEFAULT NULL COMMENT 'User ID who last updated this review',
63
64 PRIMARY KEY (`id`),
65 KEY `idx_trip_status` (`trip_id`, `status`),
66 KEY `idx_user_id` (`user_id`),
67 KEY `idx_status` (`status`),
68 KEY `idx_rating` (`rating`),
69 KEY `idx_created_at` (`created_at`)
70 ) {$charsetCollate} COMMENT='Trip reviews and ratings';
71 SQL;
72 }
73 }
74