buildDynamicQuery('vc_vendors'); $items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Vendor'); return $items; } public function createVendor() { if (isset($this->data['vendor_image'])) { $query = "INSERT INTO vc_vendors (vendor_uuid, vendor_name, vendor_slugify, vendor_description, vendor_enabled, vendor_create_timestamp, vendor_image) VALUES (UUID(), ?, ?, ?, ?, ?, ?)"; $stmt = $this->prepareStatement($query); $stmt->bind_param('ssssis', $this->data['vendor_name'], $this->data['vendor_slugify'], $this->data['vendor_description'], $this->data['vendor_enabled'], time(), $this->data['vendor_image']); } else { $query = "INSERT INTO vc_vendors (vendor_uuid, vendor_name, vendor_slugify, vendor_description, vendor_enabled, vendor_create_timestamp) VALUES (UUID(), ?, ?, ?, ?, ?)"; $stmt = $this->prepareStatement($query); $stmt->bind_param('ssssi', $this->data['vendor_name'], $this->data['vendor_slugify'], $this->data['vendor_description'], $this->data['vendor_enabled'], time()); } $this->executeStatement($stmt); $stmt->close(); $result = $this->getVendorSlugify(); if ($result->num_rows === 0) { $this->apiOutput(500, ['error' => 'Something went wrong creating the vendor on the server.'], 'error_contact_support'); } $platform_data = $result->fetch_assoc(); $this->apiOutput(200, ['success' => $platform_data], 'item_added'); } public function getVendorSlugify() { $query = "SELECT * FROM vc_vendors WHERE vendor_slugify = ?"; $stmt = $this->prepareStatement($query); $stmt->bind_param("s", $this->data['vendor_slugify']); $this->executeStatement($stmt); return $stmt->get_result(); } public function editVendor() { if (isset($this->data['vendor_image'])) { $query = "UPDATE vc_vendors SET vendor_name = ?, vendor_description = ?, vendor_enabled = ?, vendor_image = ?, vendor_modified_timestamp = ? WHERE vendor_uuid = ?"; $stmt = $this->prepareStatement($query); $stmt->bind_param("ssisis", $this->data['vendor_name'], $this->data['vendor_description'], $this->data['vendor_enabled'], $this->data['vendor_image'], time(), $this->data['vendor_uuid']); } else { $query = "UPDATE vc_vendors SET vendor_name = ?, vendor_description = ?, vendor_enabled = ?, vendor_modified_timestamp = ? WHERE vendor_uuid = ?"; $stmt = $this->prepareStatement($query); $stmt->bind_param("ssiis", $this->data['vendor_name'], $this->data['vendor_description'], $this->data['vendor_enabled'], time(), $this->data['vendor_uuid']); } if ($this->executeStatement($stmt)) { $this->apiOutput(200, ['success' => 'Platform updated successfully.']); } } }