From 3515387570e3b34dbe7239961bd93a0ced5b1175 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Sun, 1 May 2022 21:29:59 +0200 Subject: [PATCH] fixed member --- src/Api.php | 2 +- src/Member.php | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Api.php b/src/Api.php index 1cc0e2d..029b391 100644 --- a/src/Api.php +++ b/src/Api.php @@ -161,7 +161,7 @@ class Api } /** - * @return Collection + * @return Collection */ public function membershipsOf(int $memberId): Collection { diff --git a/src/Member.php b/src/Member.php index d8fec0a..d9b38ae 100644 --- a/src/Member.php +++ b/src/Member.php @@ -6,6 +6,7 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; use Zoomyboy\LaravelNami\Data\Membership; +use Zoomyboy\LaravelNami\Data\MembershipEntry; use Zoomyboy\LaravelNami\Exceptions\RightException; class Member extends Model @@ -144,7 +145,7 @@ class Member extends Model } /** - * @return Collection + * @return Collection */ public function memberships(): Collection { @@ -156,22 +157,15 @@ class Member extends Model return Nami::putMembership($this->id, $membership); } - public function deleteMembership(int $id): int + public function deleteMembership(int $id): void { - $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, - ]); + Nami::deleteMembership($this->id, $this->membership($id)); } - public function membership($id): ?Membership + public function membership(int $id): ?Membership { try { - return Membership::fromNami(Nami::membership($this->id, $id)); + return Nami::membership($this->id, $id); } catch (RightException $e) { return null; }