| | |
| | | // break; |
| | | // } |
| | | if (!isset(self::$cache)) { |
| | | self::$cache = Cache::for('user_karma')->connect('user'); |
| | | self::$cache = Cache::for('user_karma')->connect('user')->user(); |
| | | } |
| | | |
| | | add_filter(BASE.'handle_bulk_operation', [$this, 'processOperation'], 10, 3); |
| | |
| | | protected function defineTable():bool |
| | | { |
| | | $table = CustomTable::for('karma_'.$this->key); |
| | | [$type, $table, $column] = $this->getReferenceTable($table); |
| | | [$type, $referenceTable, $column] = $this->getReferenceTable($table); |
| | | if (!$type) { |
| | | error_log('[KarmaManager]::defineTable Attempted to build reference for invalid table: '.$this->references); |
| | | CustomTable::destroyInstance('karma_'.$this->key); |
| | |
| | | 'item_id' => "{$type} NOT NULL", |
| | | 'user_id' => "{$table->getUserIDType()} NOT NULL", |
| | | 'content' => 'varchar(255) NOT NULL', |
| | | 'vote' => "ENUM('up,'down') NOT NULL", |
| | | 'vote' => "ENUM('up','down') NOT NULL", |
| | | 'created_at'=> 'datetime NOT NULL DEFAULT CURRENT_TIMESTAMP', |
| | | 'updated_at'=> 'datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP' |
| | | ]); |
| | |
| | | ]); |
| | | $base = BASE; |
| | | $table->setConstraints([ |
| | | "CONSTRAINT `{$base}kt_{$type}_item_id` FOREIGN KEY (`item_id`) |
| | | REFERENCES `{$table}` (`{$column}`) ON DELETE CASCADE", |
| | | "CONSTRAINT `{$base}kt_{$type}_user_id` FOREIGN KEY (`user_id`) |
| | | "CONSTRAINT `{$base}kt_{$this->key}_{$type}_item_id` FOREIGN KEY (`item_id`) |
| | | REFERENCES `{$referenceTable}` (`{$column}`) ON DELETE CASCADE", |
| | | "CONSTRAINT `{$base}kt_{$this->key}_{$type}_user_id` FOREIGN KEY (`user_id`) |
| | | REFERENCES `{$table->getUserTable()}` (`ID`) ON DELETE CASCADE" |
| | | ]); |
| | | $table->defineTable(); |