* @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\Bin\Canary as Debug; use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Plugins\Feedback as Plugin; class Feedback extends DatabaseModel { public $tableName = 'feedback'; public $databaseMatrix = [ // userID // review_category_id // rating // review // createdAt // approvedAt [ 'name', 'varchar', '128' ], [ 'time', 'int', '10' ], [ 'email', 'varchar', '128' ], [ 'ip', 'varchar', '64' ], [ 'feedback', 'text', '' ], ]; public $plugin; /** * The model constructor. */ public function __construct() { parent::__construct(); $this->plugin = new Plugin; } /** * Saves a feedback form to the db. * * @param string $name -the name on the form * @param string $email -the email provided * @param string $feedback -contents of the feedback form. * @return bool */ public function create( $name, $email, $feedback ) { if ( !$this->plugin->checkEnabled() ) { Debug::info( 'Feedback is disabled in the config.' ); return false; } $fields = [ 'name' => $name, 'email' => $email, 'feedback' => $feedback, 'time' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], ]; if ( !self::$db->insert( $this->tableName, $fields ) ) { Debug::info( 'Feedback::create - failed to insert to db' ); return false; } return self::$db->lastId(); } } // closeNow // listSitePolls