Skip to content

Commit

Permalink
Add Remove button
Browse files Browse the repository at this point in the history
  • Loading branch information
anisAronno committed Mar 7, 2023
1 parent a9e38fa commit 2384167
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
19 changes: 18 additions & 1 deletion Http/Controllers/StripeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function index(Mailbox $mailbox)
}

/**
* Summary of update
* Update stripe key
* @param Request $request
* @return void
*/
Expand All @@ -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();
}
}
3 changes: 2 additions & 1 deletion Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
34 changes: 23 additions & 11 deletions Resources/views/stripe_settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@

<div class="row-container form-container">
<div class="row">
@if (Auth::user()->can('updateSettings', $mailbox))
<div class="col-xs-12 col-md-12">
<form class="form-horizontal margin-top" method="POST" action="" enctype="multipart/form-data">
{{ csrf_field() }}
@if (Auth::user()->can('updateSettings', $mailbox))
{{ method_field('PUT') }}
<div class="form-group{{ $errors->has('stripe_secret_key') ? ' has-error' : '' }}">
<label for="stripe_secret_key" class="col-sm-2 control-label">{{ __('Stripe Secret Key') }}</label>

<div class="col-sm-6">
<div class="flexy">
<input id="stripe_secret_key" type="text" class="form-control" name="stripe_secret_key" value="{{ old('stripe_secret_key', optional($mailbox->stripeSetting)->stripe_secret_key) }}" maxlength="255">
<input id="stripe_secret_key" type="password" class="form-control" name="stripe_secret_key" value="{{ old('stripe_secret_key', optional($mailbox->stripeSetting)->stripe_secret_key) }}" maxlength="255">
</div>

@include('partials/field_error', ['field'=>'stripe_secret_key'])
Expand All @@ -36,20 +37,31 @@

<div class="form-group">
<div class="col-sm-6 col-sm-offset-2">
<button type="submit" class="btn btn-primary">
{{ __('Save') }}
</button>
@if(optional($mailbox->stripeSetting)->stripe_secret_key == null)
<button type="submit" class="btn btn-primary">
{{ __('Save') }}
</button>
@else


<button type="submit" class="btn btn-success">
{{ __('Update') }}
</button>
@endif

<a href="javascript:void(0)" onclick="document.getElementById('deleteForm').submit();" class="btn btn-danger">
{{ __('Remove') }}
</a>
</div>
</div>

@endif
</form>
</div>
</div>

<form id="deleteForm" action="{{route('stripe.settings.destroy', $mailbox)}}" method="POST">
{{ csrf_field() }}
{{ method_field('DELETE') }}
</form>
@endif
</div>



</div>
@endsection
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 2384167

Please sign in to comment.