From 753c115b344dd3f769a1889068e95233096834d3 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 30 Oct 2021 00:49:36 +0200 Subject: [PATCH] Add success message when payment created --- app/Http/Middleware/InertiaShareMiddleware.php | 1 + app/Payment/AllpaymentController.php | 4 ++-- app/Providers/AppServiceProvider.php | 10 +++++++++- resources/js/layouts/App.vue | 2 +- tailwind.config.js | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Http/Middleware/InertiaShareMiddleware.php b/app/Http/Middleware/InertiaShareMiddleware.php index b49810d6..4150c034 100644 --- a/app/Http/Middleware/InertiaShareMiddleware.php +++ b/app/Http/Middleware/InertiaShareMiddleware.php @@ -21,6 +21,7 @@ class InertiaShareMiddleware \Inertia::share([ 'auth' => ['user' => auth()->check() ? new UserResource(auth()->user()) : null], 'search' => $request->query('search', ''), + 'flash' => session()->get('flash'), 'menu' => function() { return session()->get('menu'); }, diff --git a/app/Payment/AllpaymentController.php b/app/Payment/AllpaymentController.php index f4bfb3fe..3a893dc2 100644 --- a/app/Payment/AllpaymentController.php +++ b/app/Payment/AllpaymentController.php @@ -3,9 +3,9 @@ namespace App\Payment; use App\Http\Controllers\Controller; -use Illuminate\Http\Request; use App\Member\Member; use App\Payment\Status; +use Illuminate\Http\Request; class AllpaymentController extends Controller { @@ -30,6 +30,6 @@ class AllpaymentController extends Controller ]); } - return redirect()->back(); + return redirect()->back()->success('Zahlungen erstellt'); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 42cdbe66..6109d728 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,8 +2,9 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { @@ -17,6 +18,13 @@ class AppServiceProvider extends ServiceProvider JsonResource::withoutWrapping(); \Inertia::share('search', request()->query('search', '')); + + RedirectResponse::macro('success', function($flash) { + session()->flash('flash', ['success' => $flash]); + + return $this; + }); + } /** diff --git a/resources/js/layouts/App.vue b/resources/js/layouts/App.vue index 20d829ba..324d1cb7 100644 --- a/resources/js/layouts/App.vue +++ b/resources/js/layouts/App.vue @@ -1,7 +1,7 @@