diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index dba38ada..974dea88 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -21,8 +21,8 @@ class MemberView return [ 'data' => MemberResource::collection(Member::select('*') ->filter($filter)->search($request->query('search', null)) - ->with('billKind')->with('payments')->with('memberships')->with('courses')->with('leaderMemberships')->with('ageGroupMemberships') - ->withSubscriptionName()->withIsConfirmed()->withPendingPayment() + ->with('billKind')->with('payments.subscription')->with('memberships')->with('courses')->with('leaderMemberships')->with('ageGroupMemberships') + ->withIsConfirmed()->withPendingPayment() ->orderByRaw('lastname, firstname') ->paginate(15) ), diff --git a/app/Member/Member.php b/app/Member/Member.php index 1e5db137..2fb8d7be 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -285,13 +285,6 @@ class Member extends Model return $q->selectSub('DATEDIFF(NOW(), IFNULL(confirmed_at, DATE_SUB(NOW(), INTERVAL 3 YEAR))) < 712', 'is_confirmed'); } - public function scopeWithSubscriptionName(Builder $q): Builder - { - return $q->addSelect([ - 'subscription_name' => Subscription::select('name')->whereColumn('subscriptions.id', 'members.subscription_id')->limit(1), - ]); - } - public function scopeWithPendingPayment(Builder $q): Builder { return $q->addSelect([ diff --git a/app/Payment/PaymentResource.php b/app/Payment/PaymentResource.php index 120e90a4..88237c0d 100644 --- a/app/Payment/PaymentResource.php +++ b/app/Payment/PaymentResource.php @@ -19,6 +19,7 @@ class PaymentResource extends JsonResource public function toArray($request) { return [ + 'subscription_id' => $this->subscription_id, 'subscription' => new SubscriptionResource($this->whenLoaded('subscription')), 'status_name' => $this->status->name, 'status_id' => $this->status->id, diff --git a/resources/js/views/member/MemberPayments.vue b/resources/js/views/member/MemberPayments.vue index 1ecf5bad..c316b339 100644 --- a/resources/js/views/member/MemberPayments.vue +++ b/resources/js/views/member/MemberPayments.vue @@ -43,7 +43,7 @@