| 1 |
<?php |
| 2 |
|
| 3 |
namespace Bookit\Classes\Database; |
| 4 |
|
| 5 |
use Bookit\Classes\Vendor\DatabaseModel; |
| 6 |
|
| 7 |
class Coupons extends DatabaseModel { |
| 8 |
|
| 9 |
/** |
| 10 |
* Create Table |
| 11 |
*/ |
| 12 |
public static function create_table() { |
| 13 |
global $wpdb; |
| 14 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 15 |
|
| 16 |
$table_name = self::_table(); |
| 17 |
$primary_key = self::$primary_key; |
| 18 |
|
| 19 |
$sql = "CREATE TABLE IF NOT EXISTS {$table_name} ( |
| 20 |
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, |
| 21 |
`discount` INT UNSIGNED NOT NULL, |
| 22 |
`code` VARCHAR(255) NOT NULL, |
| 23 |
`usage_limit` INT UNSIGNED DEFAULT NULL, |
| 24 |
`once_per_user` INT UNSIGNED DEFAULT NULL, |
| 25 |
`services` longtext DEFAULT NULL, |
| 26 |
`staff` longtext DEFAULT NULL, |
| 27 |
`created_at` DATETIME NOT NULL, |
| 28 |
`updated_at` DATETIME NOT NULL, |
| 29 |
PRIMARY KEY ({$primary_key}) |
| 30 |
) {$wpdb->get_charset_collate()};"; |
| 31 |
|
| 32 |
maybe_create_table( $table_name, $sql ); |
| 33 |
} |
| 34 |
} |
| 35 |
|