Offline payment delete method check transaction.
This commit is contained in:
parent
9abda76d22
commit
3ca586a72f
@ -102,17 +102,22 @@ class Settings extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(DRequest $request)
|
public function destroy(DRequest $request)
|
||||||
{
|
{
|
||||||
$payment_method = $this->dispatch(new DeletePaymentMethod($request));
|
$response = $this->ajaxDispatch(new DeletePaymentMethod($request));
|
||||||
|
|
||||||
$message = trans('messages.success.deleted', ['type' => $payment_method['name']]);
|
if ($response['success']) {
|
||||||
|
//$response['redirect'] = route('offline-payments.settings.edit');
|
||||||
|
|
||||||
//flash($message)->success();
|
$response['message'] = trans('messages.success.deleted', ['type' => $response['data']['name']]);
|
||||||
|
|
||||||
return response()->json([
|
//flash($message)->success();
|
||||||
'errors' => false,
|
} else {
|
||||||
'success' => true,
|
//$response['redirect'] = route('offline-payments.settings.edit');
|
||||||
'message' => $message,
|
|
||||||
'redirect' => route('offline-payments.settings.edit'),
|
$message = $response['message'];
|
||||||
]);
|
|
||||||
|
//flash($message)->error();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Modules\OfflinePayments\Jobs;
|
|||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
use App\Utilities\Modules;
|
use App\Utilities\Modules;
|
||||||
|
use App\Models\Banking\Transaction;
|
||||||
|
|
||||||
class DeletePaymentMethod extends Job
|
class DeletePaymentMethod extends Job
|
||||||
{
|
{
|
||||||
@ -26,6 +27,8 @@ class DeletePaymentMethod extends Job
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$this->authorize();
|
||||||
|
|
||||||
$methods = json_decode(setting('offline-payments.methods'), true);
|
$methods = json_decode(setting('offline-payments.methods'), true);
|
||||||
|
|
||||||
$payment_method = [];
|
$payment_method = [];
|
||||||
@ -50,4 +53,31 @@ class DeletePaymentMethod extends Job
|
|||||||
|
|
||||||
return $payment_method;
|
return $payment_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this action is applicable.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
if ($relationships = $this->getRelationships()) {
|
||||||
|
$message = trans('messages.warning.deleted', ['name' => $this->request->get('code'), 'text' => implode(', ', $relationships)]);
|
||||||
|
|
||||||
|
throw new \Exception($message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelationships()
|
||||||
|
{
|
||||||
|
$counter = [];
|
||||||
|
|
||||||
|
if (!$c = Transaction::where('payment_method', $this->request->get('code'))->get()->count()) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$counter[] = $c . ' ' . strtolower(trans_choice('general.transactions', ($c > 1) ? 2 : 1));
|
||||||
|
|
||||||
|
return $counter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,10 @@ const app = new Vue({
|
|||||||
|
|
||||||
document.getElementById('method-' + this.confirm.code).remove();
|
document.getElementById('method-' + this.confirm.code).remove();
|
||||||
|
|
||||||
this.confirm.show = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.confirm.show = false;
|
||||||
|
|
||||||
this.$notify({
|
this.$notify({
|
||||||
message: response.data.message,
|
message: response.data.message,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user