1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PaymentMethodController |
5
|
|
|
* |
6
|
|
|
* This is the controller for the shop payment methods |
7
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
8
|
|
|
* @version 0.1 |
9
|
|
|
*/ |
10
|
|
|
use App\Http\Controllers\Controller; |
11
|
|
|
use Illuminate\Http\Request; |
12
|
|
|
use Notification; |
13
|
|
|
use Form; |
14
|
|
|
use Datatables; |
|
|
|
|
15
|
|
|
use Hideyo\Ecommerce\Framework\Services\PaymentMethod\PaymentMethodFacade as PaymentMethodService; |
16
|
|
|
use Hideyo\Ecommerce\Framework\Services\TaxRate\TaxRateFacade as TaxRateService; |
17
|
|
|
use Hideyo\Ecommerce\Framework\Services\Order\OrderStatusFacade as OrderStatusService; |
18
|
|
|
|
19
|
|
|
class PaymentMethodController extends Controller |
20
|
|
|
{ |
21
|
|
|
public function index(Request $request) |
22
|
|
|
{ |
23
|
|
|
if ($request->wantsJson()) { |
24
|
|
|
|
25
|
|
|
$query = PaymentMethodService::getModel()->where('shop_id', '=', auth('hideyobackend')->user()->selected_shop_id) |
|
|
|
|
26
|
|
|
->with(array('orderConfirmedOrderStatus', 'orderPaymentCompletedOrderStatus', 'orderPaymentFailedOrderStatus')); |
27
|
|
|
|
28
|
|
|
$datatables = Datatables::of($query) |
29
|
|
|
|
30
|
|
|
->addColumn('orderconfirmed', function ($query) { |
31
|
|
|
if ($query->orderConfirmedOrderStatus) { |
32
|
|
|
return $query->orderConfirmedOrderStatus->title; |
33
|
|
|
} |
34
|
|
|
}) |
35
|
|
|
->addColumn('paymentcompleted', function ($query) { |
36
|
|
|
if ($query->orderPaymentCompletedOrderStatus) { |
37
|
|
|
return $query->orderPaymentCompletedOrderStatus->title; |
38
|
|
|
} |
39
|
|
|
}) |
40
|
|
|
->addColumn('paymentfailed', function ($query) { |
41
|
|
|
if ($query->orderPaymentFailedOrderStatus) { |
42
|
|
|
return $query->orderPaymentFailedOrderStatus->title; |
43
|
|
|
} |
44
|
|
|
}) |
45
|
|
|
->addColumn('action', function ($query) { |
46
|
|
|
$deleteLink = Form::deleteajax(url()->route('payment-method.destroy', $query->id), 'Delete', '', array('class'=>'btn btn-sm btn-danger')); |
47
|
|
|
$links = '<a href="'.url()->route('payment-method.edit', $query->id).'" class="btn btn-sm btn-success"><i class="fi-pencil"></i>Edit</a> '.$deleteLink; |
48
|
|
|
return $links; |
49
|
|
|
}); |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
return $datatables->make(true); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return view('backend.payment_method.index')->with('paymentMethod', PaymentMethodService::selectAll()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function create() |
59
|
|
|
{ |
60
|
|
|
return view('backend.payment_method.create')->with( |
61
|
|
|
array( |
62
|
|
|
'taxRates' => TaxRateService::selectAll()->pluck('title', 'id'), |
63
|
|
|
'orderStatuses' => OrderStatusService::selectAll()->pluck('title', 'id') |
64
|
|
|
) |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function store(Request $request) |
69
|
|
|
{ |
70
|
|
|
$result = PaymentMethodService::create($request->all()); |
71
|
|
|
return PaymentMethodService::notificationRedirect('payment-method.index', $result, 'The payment method was inserted.'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function edit($paymentMethodId) |
75
|
|
|
{ |
76
|
|
|
return view('backend.payment_method.edit')->with( |
77
|
|
|
array( |
78
|
|
|
'paymentMethod' => PaymentMethodService::find($paymentMethodId), |
79
|
|
|
'taxRates' => TaxRateService::selectAll()->pluck('title', 'id'), |
80
|
|
|
'orderStatuses' => OrderStatusService::selectAll()->pluck('title', 'id') |
81
|
|
|
) |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function update(Request $request, $paymentMethodId) |
86
|
|
|
{ |
87
|
|
|
$result = PaymentMethodService::updateById($request->all(), $paymentMethodId); |
88
|
|
|
return PaymentMethodService::notificationRedirect('payment-method.index', $result, 'The payment method was updated.'); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function destroy($paymentMethodId) |
92
|
|
|
{ |
93
|
|
|
$result = PaymentMethodService::destroy($paymentMethodId); |
94
|
|
|
|
95
|
|
|
if ($result) { |
96
|
|
|
Notification::success('The payment method was deleted.'); |
97
|
|
|
return redirect()->route('payment-method.index'); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths