chg: [Aligntments] setAlignment function moved to its appropriate model
parent
539ce4b99a
commit
1a6505bf61
|
@ -23,4 +23,23 @@ class AlignmentsTable extends AppTable
|
|||
->requirePresence(['individual_id', 'organisation_id'], 'create');
|
||||
return $validator;
|
||||
}
|
||||
|
||||
public function setAlignment($organisation_id, $individual_id, $type): void
|
||||
{
|
||||
$query = $this->find();
|
||||
$query->where([
|
||||
'organisation_id' => $organisation_id,
|
||||
'individual_id' => $individual_id
|
||||
]);
|
||||
$existingAlignment = $query->first();
|
||||
if (empty($existingAlignment)) {
|
||||
$alignment = $this->newEmptyEntity();
|
||||
$data = [
|
||||
'organisation_id' => $organisation_id,
|
||||
'individual_id' => $individual_id,
|
||||
'type' => $type
|
||||
];
|
||||
$this->patchEntity($alignment, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue