From fa4467006f1795e61652c06a32b607f932480ba4 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 4 Jul 2021 18:29:21 +0200 Subject: [PATCH] Add beitrag --- app/Http/Views/MemberView.php | 2 +- app/Member/Member.php | 6 ++++++ app/Member/MemberResource.php | 1 + resources/js/views/member/Index.vue | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index 83c71567..b88fe68f 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -12,7 +12,7 @@ use App\Payment\PaymentResource; class MemberView { public function index(Request $request) { return [ - 'data' => MemberResource::collection(Member::select('*')->search($request->query('search', null))->with('billKind')->withIsConfirmed()->paginate(15)), + 'data' => MemberResource::collection(Member::select('*')->search($request->query('search', null))->with('billKind')->withSubscriptionName()->withIsConfirmed()->orderByRaw('lastname, firstname')->paginate(15)), 'toolbar' => [ ['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus'] ] ]; } diff --git a/app/Member/Member.php b/app/Member/Member.php index 74edde17..c5552e8b 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -140,4 +140,10 @@ class Member extends Model $q->selectSub('DATEDIFF(NOW(), IFNULL(confirmed_at, DATE_SUB(NOW(), INTERVAL 3 YEAR))) < 712', 'is_confirmed'); } + public function scopeWithSubscriptionName($q) { + return $q->addSelect([ + 'subscription_name' => Subscription::select('name')->whereColumn('subscriptions.id', 'members.subscription_id')->limit(1) + ]); + } + } diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index acbfd894..8dac4296 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -28,6 +28,7 @@ class MemberResource extends JsonResource 'joined_at_human' => $this->joined_at->format('d.m.Y'), 'id' => $this->id, 'subscription_id' => $this->subscription_id, + 'subscription_name' => $this->subscription_name, 'gender_id' => $this->gender_id, 'further_address' => $this->further_address, 'work_phone' => $this->work_phone, diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index ef0c2c60..fa99740d 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -9,6 +9,7 @@
PLZ
Ort
Tags
+
Beitrag
Rechnung
Geburtstag
Eintritt
@@ -28,6 +29,7 @@ C +
Kein