1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PaymentAmountOptionController |
5
|
|
|
* |
6
|
|
|
* This is the controller of the product amount options of the shop |
7
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
8
|
|
|
* @version 0.1 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
use App\Http\Controllers\Controller; |
12
|
|
|
|
13
|
|
|
use Dutchbridge\Datatable\ProductAmountOptionDatatable; |
|
|
|
|
14
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\ProductAmountOptionFacade as ProductAmountOptionService; |
|
|
|
|
15
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\ProductFacade as ProductService; |
16
|
|
|
use Hideyo\Ecommerce\Framework\Services\ExtraField\ExtraFieldFacade as ExtraFieldService; |
17
|
|
|
use Hideyo\Ecommerce\Framework\Services\Attribute\AttributeFacade as AttributeService; |
18
|
|
|
use Hideyo\Ecommerce\Framework\Services\TaxRate\TaxRateFacade as TaxRateService;; |
19
|
|
|
|
20
|
|
|
use Request; |
21
|
|
|
use Notification; |
22
|
|
|
use DataTables; |
23
|
|
|
use Form; |
24
|
|
|
|
25
|
|
|
class ProductAmountOptionController extends Controller |
26
|
|
|
{ |
27
|
|
|
public function index($productId) |
28
|
|
|
{ |
29
|
|
|
$datatable = new ProductAmountOptionDatatable(); |
|
|
|
|
30
|
|
|
$product = $this->product->find($productId); |
|
|
|
|
31
|
|
|
if (Request::wantsJson()) { |
32
|
|
|
|
33
|
|
|
$query = $this->productAmountOption->getModel()->where('product_id', '=', $productId); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$datatables = DataTables::of($query)->addColumn('action', function ($query) use ($productId) { |
36
|
|
|
$deleteLink = Form::deleteajax('/admin/product/'.$productId.'/product-amount-option/'. $query->id, 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
37
|
|
|
$links = '<a href="/admin/product/'.$productId.'/product-amount-option/'.$query->id.'/edit" class="btn btn-default btn-sm btn-success"><i class="entypo-pencil"></i>Edit</a> '.$deleteLink; |
38
|
|
|
|
39
|
|
|
return $links; |
40
|
|
|
}); |
41
|
|
|
|
42
|
|
|
return $datatables->make(true); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return view('backend.product-amount-option.index')->with(array('product' => $product, 'attributeGroups' => $this->attributeGroup->selectAll()->pluck('title', 'id'))); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function create($productId) |
49
|
|
|
{ |
50
|
|
|
$product = $this->product->find($productId); |
|
|
|
|
51
|
|
|
|
52
|
|
|
if (Request::wantsJson()) { |
53
|
|
|
$input = Request::all(); |
54
|
|
|
$attributeGroup = $this->attributeGroup->find($input['attribute_group_id']); |
|
|
|
|
55
|
|
|
if ($attributeGroup->count()) { |
56
|
|
|
if ($attributeGroup->attributes()) { |
57
|
|
|
return response()->json($attributeGroup->attributes); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} else { |
61
|
|
|
return view('backend.product-amount-option.create')->with(array('taxRates' => $this->taxRate->selectAll()->pluck('title', 'id'), 'product' => $product, 'attributeGroups' => $this->attributeGroup->selectAll()->pluck('title', 'id'))); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function store($productId) |
66
|
|
|
{ |
67
|
|
|
|
68
|
|
|
$result = $this->productAmountOption->create(Request::all(), $productId); |
|
|
|
|
69
|
|
|
|
70
|
|
|
if (isset($result->id)) { |
71
|
|
|
Notification::success('The product amount option is updated.'); |
72
|
|
|
return redirect()->route('admin.product.{productId}.product-amount-option.index', $productId); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
if ($result) { |
76
|
|
|
foreach ($result->errors()->all() as $error) { |
77
|
|
|
Notification::error($error); |
78
|
|
|
} |
79
|
|
|
} else { |
80
|
|
|
Notification::error('amount option already exist'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return redirect()->back()->withInput(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function edit($productId, $id) |
87
|
|
|
{ |
88
|
|
|
$product = $this->product->find($productId); |
|
|
|
|
89
|
|
|
$productAmountOption = $this->productAmountOption->find($id); |
|
|
|
|
90
|
|
|
$selectedAttributes = array(); |
91
|
|
|
$attributes = array(); |
92
|
|
|
|
93
|
|
|
return view('backend.product-amount-option.edit')->with(array('taxRates' => $this->taxRate->selectAll()->pluck('title', 'id'), 'selectedAttributes' => $selectedAttributes, 'attributes' => $attributes, 'productAmountOption' => $productAmountOption, 'product' => $product, 'attributeGroups' => $this->attributeGroup->selectAll()->pluck('title', 'id'))); |
|
|
|
|
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function update($productId, $id) |
97
|
|
|
{ |
98
|
|
|
$result = $this->productAmountOption->updateById(Request::all(), $productId, $id); |
|
|
|
|
99
|
|
|
|
100
|
|
|
if (!$result->id) { |
101
|
|
|
return redirect()->back()->withInput()->withErrors($result->errors()->all()); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
Notification::success('The product amount option is updated.'); |
105
|
|
|
return redirect()->route('admin.product.{productId}.product-amount-option.index', $productId); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function destroy($productId, $id) |
109
|
|
|
{ |
110
|
|
|
$result = $this->productAmountOption->destroy($id); |
|
|
|
|
111
|
|
|
|
112
|
|
|
if ($result) { |
113
|
|
|
Notification::success('The product amount option is deleted.'); |
114
|
|
|
return redirect()->route('admin.product.{productId}.product-amount-option.index', $productId); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
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