Delete membership
This commit is contained in:
parent
9f5324b0d0
commit
244915432b
16
src/Api.php
16
src/Api.php
|
@ -126,14 +126,22 @@ class Api {
|
|||
|
||||
public function putMembership(int $memberId, array $data): int
|
||||
{
|
||||
$url = self::$url."/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
|
||||
$response = $this->http()->post($url, $data);
|
||||
if (data_get($data, 'id')) {
|
||||
$url = self::$url."/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}/{$data['id']}";
|
||||
$response = $this->http()->put($url, $data);
|
||||
} else {
|
||||
$url = self::$url."/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
$response = $this->http()->post($url, $data);
|
||||
}
|
||||
if (data_get($response->json(), 'success') !== true) {
|
||||
$this->exception('Update failed', ['url' => $url, 'data' => $data], $response->json());
|
||||
}
|
||||
|
||||
return $response->json()['data'];
|
||||
if (data_get($data, 'id')) {
|
||||
return $response->json()['data']['id'];
|
||||
} else {
|
||||
return $response->json()['data'];
|
||||
}
|
||||
}
|
||||
|
||||
public function membershipsOf($memberId): Collection {
|
||||
|
|
|
@ -158,7 +158,19 @@ class Member extends Model {
|
|||
'gruppierungId' => $data['group_id'],
|
||||
'taetigkeitId' => $data['activity_id'],
|
||||
'untergliederungId' => $data['subactivity_id'],
|
||||
'aktivVon' => $data['created_at']->format('Y-m-d').'T00:00:00',
|
||||
'aktivVon' => $data['starts_at']->format('Y-m-d').'T00:00:00',
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteMembership(int $id): int
|
||||
{
|
||||
$membership = $this->membership($id);
|
||||
|
||||
return Nami::putMembership($this->id, [
|
||||
'gruppierungId' => $membership->group_id,
|
||||
'aktivVon' => $membership->starts_at.'T00:00:00',
|
||||
'aktivBis' => now()->format('Y-m-d').'T00:00:00',
|
||||
'id' => $membership->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue