Fix handling of existing organisation name/slug clashes

This commit is contained in:
2022-02-08 09:34:09 +00:00
parent 7353801ca9
commit 19afb760a1

View File

@@ -87,12 +87,12 @@ class OrganisationController extends SimpleController
$classMapper = $this->ci->classMapper; $classMapper = $this->ci->classMapper;
// Check if name or slug already exists // Check if name or slug already exists
if ($classMapper->getClassMapping('organisation')::where('name', $data['name'])->first()) { if ($classMapper->getClassMapping('organisation')::findUnique($data['name'], 'name')) {
$ms->addMessageTranslated('danger', 'ORGANISATION.NAME.IN_USE', $data); $ms->addMessageTranslated('danger', 'ORGANISATION.NAME.IN_USE', $data);
$error = true; $error = true;
} }
if ($classMapper->getClassMapping('organisation')::where('slug', $data['slug'])->first()) { if ($classMapper->getClassMapping('organisation')::findUnique($data['slug'], 'slug')) {
$ms->addMessageTranslated('danger', 'ORGANISATION.SLUG.IN_USE', $data); $ms->addMessageTranslated('danger', 'ORGANISATION.SLUG.IN_USE', $data);
$error = true; $error = true;
} }