1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
2
|
|
|
|
3
|
|
|
use App\Http\Controllers\Controller; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* CouponController |
7
|
|
|
* |
8
|
|
|
* This is the controller for the shop clients |
9
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
10
|
|
|
* @version 0.1 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use Hideyo\Ecommerce\Framework\Services\Coupon\CouponFacade as CouponService; |
15
|
|
|
|
16
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\ProductFacade as ProductService; |
17
|
|
|
use Hideyo\Ecommerce\Framework\Services\ProductCategory\ProductCategoryFacade as ProductCategoryService; |
18
|
|
|
use Hideyo\Ecommerce\Framework\Services\SendingMethod\SendingMethodFacade as SendingMethodService; |
19
|
|
|
use Hideyo\Ecommerce\Framework\Services\PaymentMethod\PaymentMethodFacade as PaymentMethodService; |
20
|
|
|
|
21
|
|
|
use Illuminate\Http\Request; |
22
|
|
|
use Notification; |
23
|
|
|
use Datatables; |
|
|
|
|
24
|
|
|
use Form; |
25
|
|
|
|
26
|
|
|
class CouponController extends Controller |
27
|
|
|
{ |
28
|
|
|
public function index(Request $request) |
29
|
|
|
{ |
30
|
|
|
if ($request->wantsJson()) { |
31
|
|
|
$query = CouponService::getModel()->select(['active','id', 'title', 'code']) |
32
|
|
|
->where(CouponService::getModel()->getTable().'.shop_id', '=', auth('hideyobackend')->user()->selected_shop_id) |
|
|
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
|
->with(array('couponGroup')); |
36
|
|
|
|
37
|
|
|
$datatables = Datatables::of($query) |
38
|
|
|
|
39
|
|
|
->filterColumn('title', function ($query, $keyword) { |
40
|
|
|
$query->whereRaw("coupon.title like ?", ["%{$keyword}%"]); |
41
|
|
|
}) |
42
|
|
|
|
43
|
|
|
->addColumn('action', function ($query) { |
44
|
|
|
$deleteLink = Form::deleteajax('/admin/coupon/'. $query->id, 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
45
|
|
|
$links = '<a href="/admin/coupon/'.$query->id.'/edit" class="btn btn-default btn-sm btn-success"><i class="entypo-pencil"></i>Edit</a> '.$deleteLink; |
46
|
|
|
|
47
|
|
|
return $links; |
48
|
|
|
}); |
49
|
|
|
|
50
|
|
|
return $datatables->make(true); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return view('backend.coupon.index')->with('coupon', CouponService::selectAll()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function create() |
57
|
|
|
{ |
58
|
|
|
return view('backend.coupon.create')->with(array( |
59
|
|
|
'products' => ProductService::selectAll()->pluck('title', 'id'), |
60
|
|
|
'productCategories' => ProductCategoryService::selectAll()->pluck('title', 'id'), |
61
|
|
|
'groups' => CouponService::selectAllGroups()->pluck('title', 'id')->toArray(), |
62
|
|
|
'sendingMethods' => SendingMethodService::selectAll()->pluck('title', 'id'), |
63
|
|
|
'paymentMethods' => PaymentMethodService::selectAll()->pluck('title', 'id') |
64
|
|
|
)); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function store(Request $request) |
68
|
|
|
{ |
69
|
|
|
$result = CouponService::create($request->all()); |
70
|
|
|
return CouponService::notificationRedirect('coupon.index', $result, 'The coupon was inserted.'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function edit($couponId) |
74
|
|
|
{ |
75
|
|
|
return view('backend.coupon.edit')->with( |
76
|
|
|
array( |
77
|
|
|
'coupon' => CouponService::find($couponId), |
78
|
|
|
'products' => ProductService::selectAll()->pluck('title', 'id'), |
79
|
|
|
'groups' => CouponService::selectAllGroups()->pluck('title', 'id')->toArray(), |
80
|
|
|
'productCategories' => ProductCategoryService::selectAll()->pluck('title', 'id'), |
81
|
|
|
'sendingMethods' => SendingMethodService::selectAll()->pluck('title', 'id'), |
82
|
|
|
'paymentMethods' => PaymentMethodService::selectAll()->pluck('title', 'id'), |
83
|
|
|
) |
84
|
|
|
); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function update(Request $request, $couponId) |
88
|
|
|
{ |
89
|
|
|
$result = CouponService::updateById($request->all(), $couponId); |
90
|
|
|
return CouponService::notificationRedirect('coupon.index', $result, 'The coupon was updated.'); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function destroy($couponId) |
94
|
|
|
{ |
95
|
|
|
$result = CouponService::destroy($couponId); |
96
|
|
|
|
97
|
|
|
if ($result) { |
98
|
|
|
Notification::success('The coupon was deleted.'); |
99
|
|
|
return redirect()->route('coupon.index'); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
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