* @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\Dashboards as Plugin; class Dashboards extends DatabaseModel { public $tableName = 'dashboards'; public $databaseMatrix = [ [ 'name', 'varchar', '128' ], ]; public $plugin; /** * The model constructor. */ public function __construct() { parent::__construct(); $this->plugin = new Plugin; } public function create( $name, $email, $dashboard ) { if ( !$this->plugin->checkEnabled() ) { Debug::info( 'Dashboards are disabled in the config.' ); return false; } $fields = [ 'name' => $name, 'email' => $email, 'time' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], ]; if ( !self::$db->insert( $this->tableName, $fields ) ) { Debug::info( 'Dashboards::create - failed to insert to db' ); return false; } return self::$db->lastId(); } }