PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / InstallActions / DB / Notification / NotificationsTable.php
ameliabooking / src / Infrastructure / WP / InstallActions / DB / Notification Last commit date
NotificationsLogTable.php 1 month ago NotificationsSMSHistoryTable.php 2 months ago NotificationsTable.php 2 months ago NotificationsTableInsertRows.php 6 months ago NotificationsToEntitiesTable.php 2 months ago
NotificationsTable.php
67 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\WP\InstallActions\DB\Notification;
4
5 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
6 use AmeliaBooking\Domain\ValueObjects\String\Name;
7 use AmeliaBooking\Domain\ValueObjects\String\NotificationSendTo;
8 use AmeliaBooking\Domain\ValueObjects\String\NotificationType;
9 use AmeliaBooking\Infrastructure\WP\InstallActions\DB\AbstractDatabaseTable;
10
11 /**
12 * Class NotificationsTable
13 *
14 * @package AmeliaBooking\Infrastructure\WP\InstallActions\DB\Notification
15 */
16 class NotificationsTable extends AbstractDatabaseTable
17 {
18 public const TABLE = 'notifications';
19
20 /**
21 * @return string
22 * @throws InvalidArgumentException
23 */
24 public static function buildTable()
25 {
26 global $wpdb;
27
28 $table = self::getTableName();
29
30 $charsetCollate = self::getCharsetCollate();
31
32 $name = Name::MAX_LENGTH;
33 $typeEmail = NotificationType::EMAIL;
34 $typeSms = NotificationType::SMS;
35 $typeWhatsApp = NotificationType::WHATSAPP;
36 $sendToCustomer = NotificationSendTo::CUSTOMER;
37 $sendToProvider = NotificationSendTo::PROVIDER;
38
39 if (
40 $wpdb->get_var("SHOW TABLES LIKE '{$table}'") === $table &&
41 $wpdb->query("SHOW KEYS FROM {$table} WHERE Key_name = 'name'")
42 ) {
43 $wpdb->query("ALTER TABLE {$table} DROP INDEX name");
44 }
45
46 return "CREATE TABLE {$table} (
47 `id` INT(11) NOT NULL AUTO_INCREMENT,
48 `name` VARCHAR({$name}) NOT NULL DEFAULT '',
49 `customName` VARCHAR(255) DEFAULT NULL,
50 `status` ENUM('enabled', 'disabled') NOT NULL DEFAULT 'enabled',
51 `type` ENUM('{$typeEmail}', '{$typeSms}', '{$typeWhatsApp}') NOT NULL,
52 `entity` ENUM('appointment', 'event') NOT NULL DEFAULT 'appointment',
53 `time` TIME NULL DEFAULT NULL,
54 `timeBefore` INT(11) NULL DEFAULT NULL,
55 `timeAfter` INT(11) NULL DEFAULT NULL,
56 `sendTo` ENUM('{$sendToCustomer}', '{$sendToProvider}') NOT NULL,
57 `subject` VARCHAR(255) NOT NULL DEFAULT '',
58 `content` TEXT NULL,
59 `translations` TEXT NULL DEFAULT NULL,
60 `sendOnlyMe` TINYINT(1) DEFAULT 0,
61 `whatsAppTemplate` VARCHAR(255) NULL DEFAULT NULL,
62 `minimumTimeBeforeBooking` TEXT NULL DEFAULT NULL,
63 PRIMARY KEY (`id`)
64 ) {$charsetCollate};";
65 }
66 }
67