From 45af77fb44e535d97411a7a580c5cb96c3f54734 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 22 Aug 2021 05:15:56 +0200 Subject: [PATCH] Create own view for paymentsForm --- app/Http/Views/MemberView.php | 19 +++------- app/Payment/PaymentController.php | 18 +++------- resources/js/views/member/Index.vue | 30 +++++++++++----- resources/js/views/member/PaymentForm.vue | 44 ----------------------- resources/js/views/member/Payments.vue | 42 ++++++++++++++++++---- 5 files changed, 65 insertions(+), 88 deletions(-) delete mode 100644 resources/js/views/member/PaymentForm.vue diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index 22f9fe39..0f8fcab6 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -13,23 +13,14 @@ use Illuminate\Http\Request; class MemberView { public function index(Request $request) { return [ - 'data' => MemberResource::collection(Member::select('*')->search($request->query('search', null))->with('billKind')->withSubscriptionName()->withIsConfirmed()->withPendingPayment()->orderByRaw('lastname, firstname')->paginate(15)), - 'toolbar' => [ ['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus'] ] + 'data' => MemberResource::collection(Member::select('*')->search($request->query('search', null))->with('billKind')->with('payments')->withSubscriptionName()->withIsConfirmed()->withPendingPayment()->orderByRaw('lastname, firstname')->paginate(15)), + 'toolbar' => [ ['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus'] ], + 'paymentDefaults' => ['nr' => date('Y')], + 'subscriptions' => Subscription::get()->pluck('name', 'id'), + 'statuses' => Status::get()->pluck('name', 'id'), ]; } - public function paymentCreate($member) { - return $this->additional($member, [ - 'model' => [ - 'subscription_id' => $member->subscription_id, - 'status_id' => Status::default(), - 'nr' => date('Y'), - ], - 'links' => [ ['label' => 'Zurück', 'href' => route('member.payment.index', ['member' => $member]) ] ], - 'mode' => 'create', - ]); - } - public function paymentEdit($member, $payment) { return $this->additional($member, [ 'model' => new PaymentResource($payment), diff --git a/app/Payment/PaymentController.php b/app/Payment/PaymentController.php index 2a023f05..fc189fbf 100644 --- a/app/Payment/PaymentController.php +++ b/app/Payment/PaymentController.php @@ -3,10 +3,10 @@ namespace App\Payment; use App\Http\Controllers\Controller; -use Illuminate\Http\Request; +use App\Http\Views\MemberView; use App\Member\Member; use App\Member\MemberResource; -use App\Http\Views\MemberView; +use Illuminate\Http\Request; class PaymentController extends Controller { @@ -20,16 +20,6 @@ class PaymentController extends Controller return \Inertia::render('member/Index', $payload); } - public function create(Member $member, Request $request) { - session()->put('menu', 'member'); - session()->put('title', "Zahlungen für Mitglied {$member->fullname}"); - - $payload = app(MemberView::class)->index($request); - $payload['single'] = app(MemberView::class)->paymentCreate($member); - - return \Inertia::render('member/Index', $payload); - } - public function store(Request $request, Member $member) { $member->payments()->create($request->validate([ 'nr' => 'required|numeric', @@ -57,12 +47,12 @@ class PaymentController extends Controller 'status_id' => 'required|exists:statuses,id', ])); - return redirect()->route('member.payment.index', ['member' => $member]); + return redirect()->back(); } public function destroy(Request $request, Member $member, Payment $payment) { $payment->delete(); - return redirect()->route('member.payment.index', ['member' => $member]); + return redirect()->back(); } } diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index 06ae69ab..519a2068 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -46,7 +46,7 @@
- +
@@ -58,9 +58,7 @@ - - - + @@ -68,30 +66,44 @@ diff --git a/resources/js/views/member/PaymentForm.vue b/resources/js/views/member/PaymentForm.vue deleted file mode 100644 index 0452a8cf..00000000 --- a/resources/js/views/member/PaymentForm.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - diff --git a/resources/js/views/member/Payments.vue b/resources/js/views/member/Payments.vue index fedc51c3..c90ae2f7 100644 --- a/resources/js/views/member/Payments.vue +++ b/resources/js/views/member/Payments.vue @@ -1,8 +1,15 @@