Files
thetempusproject/app/plugins/tablefinder/models/tables.php
2024-08-04 21:15:59 -04:00

94 lines
2.7 KiB
PHP

<?php
/**
* app/plugins/tablefinder/models/players.php
*
* This class is used for the manipulation of the feedback database table.
*
* @package TP TableFinder
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Tablefinder as Plugin;
class Players extends DatabaseModel {
public $tableName = 'players';
public $databaseMatrix = [
[ 'name', 'int', '10' ],
[ 'description', 'int', '10' ],
[ 'rules', 'int', '10' ],
[ 'gmID', 'int', '10' ],
[ 'createdAt', 'int', '10' ],
[ 'createdBy', 'int', '10' ],
[ 'calendarID', 'int', '10' ],
[ 'preferredSessionFrequency', 'int', '10' ],
// weekly
// bi-weekly
// monthly
// undefined
[ 'preferredSessionLength', 'int', '10' ],
[ 'minimumSessionLength', 'int', '10' ],
[ 'maximumSessionLength', 'int', '10' ],
[ 'gamePlatform', 'int', '10' ],
[ 'gameVersion', 'int', '10' ],
[ 'playType', 'int', '10' ],
// in-person
// online
[ 'location', 'int', '10' ],
];
public $plugin;
/**
* The model constructor.
*/
public function __construct() {
parent::__construct();
$this->plugin = new Plugin;
}
public function create(
$name,
$description = '',
$rules = '',
$frequency = 'Weekly',
$lengthPref = '4h',
$lengthMin = '30m',
$lengthMax = '12h',
$platform = 'Dungeons & Dragons',
$version = '5e',
$playType = 'Online',
$location = 'TBD'
) {
if ( !$this->plugin->checkEnabled() ) {
Debug::info( 'TableFinder is disabled in the config.' );
return false;
}
$fields = [
'userID' => $userID,
'tableID' => $tableID,
];
if ( ! empty( $characterID ) ) {
$fields['characterID'] = $characterID;
}
if ( 'apply' == $type ) {
$fields['applicationDate'] = time();
} else {
$fields['joinDate'] = time();
}
if ( !self::$db->insert( $this->tableName, $fields ) ) {
Debug::info( 'TableFinder::create - failed to insert to db' );
return false;
}
return self::$db->lastId();
}
}