public function detach($parent, string $field, &$entity) : bool
{
$fieldValue = (array) $parent->{$field};
$newId = $this->getId($entity);
foreach ($fieldValue as $key => $id) {
if ($id == $newId) {
unset($fieldValue[$key]);
}
}
$parent->{$field} = array_values($fieldValue);
return true;
}