From 238416748cac5f91712ad2105abf40e9b86023a3 Mon Sep 17 00:00:00 2001 From: "Md. Anichur Rahaman" <38912435+anis3139@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:12:23 +0600 Subject: [PATCH] Add Remove button --- Http/Controllers/StripeController.php | 19 ++++++++++++- Http/routes.php | 3 +- Resources/views/stripe_settings.blade.php | 34 +++++++++++++++-------- composer.json | 2 +- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Http/Controllers/StripeController.php b/Http/Controllers/StripeController.php index 72c9d94..7b7c489 100644 --- a/Http/Controllers/StripeController.php +++ b/Http/Controllers/StripeController.php @@ -42,7 +42,7 @@ public function index(Mailbox $mailbox) } /** - * Summary of update + * Update stripe key * @param Request $request * @return void */ @@ -69,4 +69,21 @@ public function update(Request $request, Mailbox $mailbox) return redirect()->route('stripe.settings', $mailbox->id); } + + /** + * Delete stripe key + * @param Request $request + * @return void + */ + public function destroy(Request $request, Mailbox $mailbox) + { + try { + $mailbox->stripeSetting()->delete(); + \Session::flash('flash_success_floating', __('Secret Key delete Successfully')); + } catch (DecryptException $th) { + \Session::flash('flash_error_floating', __($th->getMessage())); + } + + return redirect()->back(); + } } diff --git a/Http/routes.php b/Http/routes.php index 2698a5d..9387bde 100644 --- a/Http/routes.php +++ b/Http/routes.php @@ -2,5 +2,6 @@ Route::group(['middleware' => 'web', 'prefix' => \Helper::getSubdirectory(), 'namespace' => 'Modules\Stripe\Http\Controllers'], function () { Route::get('/stripe/settings/{mailbox}', 'StripeController@index')->name('stripe.settings'); - Route::post('/stripe/settings/{mailbox}', 'StripeController@update')->name('stripe.settings.update'); + Route::put('/stripe/settings/{mailbox}', 'StripeController@update')->name('stripe.settings.update'); + Route::delete('/stripe/settings/{mailbox}', 'StripeController@destroy')->name('stripe.settings.destroy'); }); diff --git a/Resources/views/stripe_settings.blade.php b/Resources/views/stripe_settings.blade.php index 5eab733..d77415e 100644 --- a/Resources/views/stripe_settings.blade.php +++ b/Resources/views/stripe_settings.blade.php @@ -18,16 +18,17 @@
+ @if (Auth::user()->can('updateSettings', $mailbox))
{{ csrf_field() }} - @if (Auth::user()->can('updateSettings', $mailbox)) + {{ method_field('PUT') }}
- +
@include('partials/field_error', ['field'=>'stripe_secret_key']) @@ -36,20 +37,31 @@
- + @if(optional($mailbox->stripeSetting)->stripe_secret_key == null) + + @else - + + @endif + + + {{ __('Remove') }} +
- @endif
-
+ +
+ {{ csrf_field() }} + {{ method_field('DELETE') }} +
+ @endif
- - - +
@endsection \ No newline at end of file diff --git a/composer.json b/composer.json index 4d1a417..66ee3c2 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "wedevs_official/laravel_freescout_stripe_module", "description": "Freescout stripe modules", - "version": "1.0.0", + "version": "1.0.1", "keywords": [ "helpdesk", "help desk",