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 DataTables; |
22
|
|
|
use Form; |
23
|
|
|
|
24
|
|
|
class ProductAmountOptionController extends Controller |
25
|
|
|
{ |
26
|
|
|
public function index($productId) |
27
|
|
|
{ |
28
|
|
|
$datatable = new ProductAmountOptionDatatable(); |
|
|
|
|
29
|
|
|
$product = $this->product->find($productId); |
|
|
|
|
30
|
|
|
if (Request::wantsJson()) { |
31
|
|
|
|
32
|
|
|
$query = $this->productAmountOption->getModel()->where('product_id', '=', $productId); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$datatables = DataTables::of($query)->addColumn('action', function ($query) use ($productId) { |
35
|
|
|
$deleteLink = Form::deleteajax('/admin/product/'.$productId.'/product-amount-option/'. $query->id, 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
36
|
|
|
$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; |
37
|
|
|
|
38
|
|
|
return $links; |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
return $datatables->make(true); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return view('backend.product-amount-option.index')->with(array('product' => $product, 'attributeGroups' => $this->attributeGroup->selectAll()->pluck('title', 'id'))); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function create($productId) |
48
|
|
|
{ |
49
|
|
|
$product = $this->product->find($productId); |
|
|
|
|
50
|
|
|
|
51
|
|
|
if (Request::wantsJson()) { |
52
|
|
|
$input = Request::all(); |
53
|
|
|
$attributeGroup = $this->attributeGroup->find($input['attribute_group_id']); |
|
|
|
|
54
|
|
|
if ($attributeGroup->count()) { |
55
|
|
|
if ($attributeGroup->attributes()) { |
56
|
|
|
return response()->json($attributeGroup->attributes); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} else { |
60
|
|
|
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'))); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function store($productId) |
65
|
|
|
{ |
66
|
|
|
|
67
|
|
|
$result = $this->productAmountOption->create(Request::all(), $productId); |
|
|
|
|
68
|
|
|
|
69
|
|
|
if (isset($result->id)) { |
70
|
|
|
flash('The product amount option is updated.'); |
71
|
|
|
return redirect()->route('admin.product.{productId}.product-amount-option.index', $productId); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
if ($result) { |
75
|
|
|
foreach ($result->errors()->all() as $error) { |
76
|
|
|
flash($error); |
77
|
|
|
} |
78
|
|
|
} else { |
79
|
|
|
flash('amount option already exist'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return redirect()->back()->withInput(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function edit($productId, $id) |
86
|
|
|
{ |
87
|
|
|
$product = $this->product->find($productId); |
|
|
|
|
88
|
|
|
$productAmountOption = $this->productAmountOption->find($id); |
|
|
|
|
89
|
|
|
$selectedAttributes = array(); |
90
|
|
|
$attributes = array(); |
91
|
|
|
|
92
|
|
|
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'))); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function update($productId, $id) |
96
|
|
|
{ |
97
|
|
|
$result = $this->productAmountOption->updateById(Request::all(), $productId, $id); |
|
|
|
|
98
|
|
|
|
99
|
|
|
if (!$result->id) { |
100
|
|
|
return redirect()->back()->withInput()->withErrors($result->errors()->all()); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
flash('The product amount option is updated.'); |
104
|
|
|
return redirect()->route('admin.product.{productId}.product-amount-option.index', $productId); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function destroy($productId, $id) |
108
|
|
|
{ |
109
|
|
|
$result = $this->productAmountOption->destroy($id); |
|
|
|
|
110
|
|
|
|
111
|
|
|
if ($result) { |
112
|
|
|
flash('The product amount option is deleted.'); |
113
|
|
|
return redirect()->route('admin.product.{productId}.product-amount-option.index', $productId); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
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