From 782983686ba990b57e1d0ec4c02c274ea25c96a6 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 4 Jul 2021 19:09:59 +0200 Subject: [PATCH] Add: delete member --- app/Member/Member.php | 4 ++++ app/Member/MemberController.php | 11 +++++++++++ resources/js/views/member/Index.vue | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/app/Member/Member.php b/app/Member/Member.php index c5552e8b..1a69b1bb 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -133,6 +133,10 @@ class Member extends Model $model->bill_kind_id = null; } }); + + static::deleting(function($model) { + $model->payments->each->delete(); + }); } // ---------------------------------- Scopes ----------------------------------- diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index a5a312c2..54bd37f2 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -14,6 +14,7 @@ use App\Activity; use App\Group; use App\Payment\Subscription; use App\Http\Views\MemberView; +use App\Member\DeleteJob; class MemberController extends Controller { @@ -81,4 +82,14 @@ class MemberController extends Controller return redirect()->route('member.index'); } + + public function destroy(Member $member) { + if ($member->has_nami) { + DeleteJob::dispatch($member, auth()->user()); + } + + $member->delete(); + + return redirect()->back(); + } } diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index fa99740d..3f6300fb 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -39,6 +39,7 @@
+
@@ -62,10 +63,19 @@ import Payments from './Payments.vue'; import PaymentForm from './PaymentForm.vue'; export default { + layout: App, components: { Payments, PaymentForm }, + methods: { + remove(member) { + if (window.confirm('Mitglied löschen?')) { + this.$inertia.delete(`/member/${member.id}`); + } + } + }, + props:{ data: {}, single: {