public function save()
{
$tableName = "";
if ($this->model instanceof Workspace\Asset) {
$tableName = "users_workspaces_asset";
} elseif ($this->model instanceof Workspace\Document) {
$tableName = "users_workspaces_document";
} elseif ($this->model instanceof Workspace\Object) {
$tableName = "users_workspaces_object";
}
$data = [];
// add all permissions
$dataRaw = get_object_vars($this->model);
foreach ($dataRaw as $key => $value) {
if (in_array($key, $this->getValidTableColumns($tableName))) {
if (is_bool($value)) {
$value = (int) $value;
}
$data[$key] = $value;
}
}
$this->db->insert($tableName, $data);
}