Upgrades
4 months ago
AudioPresets.php
1 year ago
EmailCollection.php
1 year ago
Migrations.php
1 year ago
Presets.php
1 year ago
Table.php
1 year ago
Videos.php
1 year ago
Visits.php
1 year ago
Webhooks.php
1 year ago
Webhooks.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrestoPlayer\Database; |
| 4 | |
| 5 | use PrestoPlayer\Database\Table; |
| 6 | |
| 7 | class Webhooks { |
| 8 | |
| 9 | protected $table; |
| 10 | |
| 11 | protected $version = 1; |
| 12 | |
| 13 | protected $name = 'presto_player_webhooks'; |
| 14 | |
| 15 | public function __construct( Table $table ) { |
| 16 | $this->table = $table; |
| 17 | } |
| 18 | |
| 19 | public function getName() { |
| 20 | global $wpdb; |
| 21 | return $wpdb->prefix . $this->name; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Add relationships custom table |
| 26 | * This allows for simple, efficient queries |
| 27 | * |
| 28 | * @return void |
| 29 | */ |
| 30 | public function install() { |
| 31 | return $this->table->create( |
| 32 | $this->name, |
| 33 | ' |
| 34 | id bigint(20) unsigned NOT NULL auto_increment, |
| 35 | name varchar(155) NULL, |
| 36 | url varchar(255) NULL, |
| 37 | method varchar(155) NULL, |
| 38 | email_name varchar(155) NULL, |
| 39 | headers varchar(255) NULL, |
| 40 | created_by bigint(20) unsigned NULL, |
| 41 | created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), |
| 42 | updated_at TIMESTAMP NOT NULL, |
| 43 | deleted_at TIMESTAMP NULL, |
| 44 | PRIMARY KEY (id), |
| 45 | KEY name (name) |
| 46 | ', |
| 47 | $this->version |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Uninstall tables |
| 53 | * |
| 54 | * @return void |
| 55 | */ |
| 56 | public function uninstall() { |
| 57 | $this->table->drop( $this->getName() ); |
| 58 | } |
| 59 | |
| 60 | public function exists() { |
| 61 | return $this->table->exists( $this->name ); |
| 62 | } |
| 63 | } |
| 64 |