Skip to content
Snippets Groups Projects
Verified Commit 7def6c92 authored by Damien's avatar Damien
Browse files

FEAT #7737 Fix update

parent 062f9951
No related branches found
No related tags found
No related merge requests found
......@@ -116,13 +116,14 @@ class TemplateController
return $response->withStatus(400)->withJson(['errors' => 'Template does not exist']);
}
TemplateModel::update(['set' => $data, 'where' => ['template_id = ?'], 'data' => [$aArgs['id']]]);
if (!empty($data['entities']) && is_array($data['entities'])) {
TemplateAssociationModel::delete(['where' => ['template_id = ?'], 'data' => [$aArgs['id']]]);
foreach ($data['entities'] as $entity) {
TemplateAssociationModel::create(['templateId' => $aArgs['id'], 'entityId' => $entity]);
}
}
unset($data['entities']);
TemplateModel::update(['set' => $data, 'where' => ['template_id = ?'], 'data' => [$aArgs['id']]]);
HistoryController::add([
'tableName' => 'templates',
'recordId' => $aArgs['id'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment