From 09b2c4fc6fc43d18737c679ca32a3af37e8f16d9 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Sun, 1 May 2022 21:30:14 +0200 Subject: [PATCH] update laravel-nami --- app/Member/CreateJob.php | 23 ++++------------------- app/Member/Member.php | 6 +++++- packages/laravel-nami | 2 +- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/app/Member/CreateJob.php b/app/Member/CreateJob.php index da431078..16fb60cf 100644 --- a/app/Member/CreateJob.php +++ b/app/Member/CreateJob.php @@ -2,11 +2,9 @@ namespace App\Member; -use App\Activity; +use App\Actions\MemberPullAction; use App\Confession; -use App\Group; use App\Setting\NamiSettings; -use App\Subactivity; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -67,22 +65,9 @@ class CreateJob implements ShouldQueue 'first_activity_id' => $member->firstActivity->nami_id, 'first_subactivity_id' => $member->firstSubactivity->nami_id, ]); - Member::withoutEvents(function () use ($response, $api, $member) { - $version = $api->member($member->group->nami_id, $response['id'])['version']; - $member->update(['version' => $version, 'nami_id' => $response['id']]); + Member::withoutEvents(function () use ($response, $member, $api) { + $member->update(['nami_id' => $response['id']]); + app(MemberPullAction::class)->member($member->group->nami_id, $member->nami_id)->api($api)->execute(); }); - - $memberships = $member->getNamiMemberships($api); - foreach ($memberships as $membership) { - $member->memberships()->create([ - 'activity_id' => Activity::nami($membership['activity_id'])->id, - 'subactivity_id' => $membership['subactivity_id'] - ? Subactivity::nami($membership['subactivity_id'])->id - : null, - 'group_id' => Group::nami($membership['group_id'])->id, - 'nami_id' => $membership['id'], - 'created_at' => $membership['starts_at'], - ]); - } } } diff --git a/app/Member/Member.php b/app/Member/Member.php index 46b7909d..4e2f63f0 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -21,6 +21,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Notifications\Notifiable; use Zoomyboy\LaravelNami\Api; +use Zoomyboy\LaravelNami\Data\MembershipEntry; /** * @property string $subscription_name @@ -100,9 +101,12 @@ class Member extends Model return null !== $this->nami_id; } + /** + * @return Collection + */ public function getNamiMemberships(Api $api): array { - return $api->group($this->group->nami_id)->member($this->nami_id)->memberships()->toArray(); + return $api->group($this->group->nami_id)->member($this->nami_id)->memberships(); } public function getNamiFeeId(): ?int diff --git a/packages/laravel-nami b/packages/laravel-nami index 5f667686..35153875 160000 --- a/packages/laravel-nami +++ b/packages/laravel-nami @@ -1 +1 @@ -Subproject commit 5f667686d0643473c0674b74cafda9154e8e84f7 +Subproject commit 3515387570e3b34dbe7239961bd93a0ced5b1175