|
1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ProductAmountSeriesController |
|
5
|
|
|
* |
|
6
|
|
|
* This is the controller of the product amount series of the shop |
|
7
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
|
8
|
|
|
* @version 0.1 |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
use App\Http\Controllers\Controller; |
|
12
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\Entity\ProductAmountSeriesRepository; |
|
13
|
|
|
use Hideyo\Ecommerce\Framework\Services\Product\ProductFacade as ProductService; |
|
14
|
|
|
use Illuminate\Http\Request; |
|
15
|
|
|
use Notification; |
|
16
|
|
|
use Datatables; |
|
|
|
|
|
|
17
|
|
|
use Form; |
|
18
|
|
|
|
|
19
|
|
|
class ProductAmountSeriesController extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
public function __construct(ProductAmountSeriesRepository $productAmountSeries) |
|
22
|
|
|
{ |
|
23
|
|
|
$this->productAmountSeries = $productAmountSeries; |
|
|
|
|
|
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function index(Request $request, $productId) |
|
27
|
|
|
{ |
|
28
|
|
|
$product = ProductService::find($productId); |
|
29
|
|
|
if ($request->wantsJson()) { |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
$query = $this->productAmountSeries->getModel()->select( |
|
33
|
|
|
['id', 'series_start', 'series_value', 'active','series_max'] |
|
34
|
|
|
)->where('product_id', '=', $productId); |
|
35
|
|
|
|
|
36
|
|
|
$datatables = Datatables::of($query) |
|
37
|
|
|
|
|
38
|
|
|
->addColumn('active', function ($query) { |
|
39
|
|
|
if ($query->active) { |
|
40
|
|
|
return '<a href="#" class="change-active" data-url="/admin/html-block/change-active/'.$query->id.'"><span class="glyphicon glyphicon-ok icon-green"></span></a>'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return '<a href="#" class="change-active" data-url="/admin/html-block/change-active/'.$query->id.'"><span class="glyphicon glyphicon-remove icon-red"></span></a>'; |
|
44
|
|
|
}) |
|
45
|
|
|
->addColumn('action', function ($query) use ($productId) { |
|
46
|
|
|
$deleteLink = Form::deleteajax(url()->route('product.product-amount-series.destroy', array('productId' => $productId, 'id' => $query->id)), 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
|
47
|
|
|
$links = '<a href="'.url()->route('product.product-amount-series.edit', array('productId' => $productId, 'id' => $query->id)).'" class="btn btn-default btn-sm btn-success"><i class="entypo-pencil"></i>Edit</a> '.$deleteLink; |
|
48
|
|
|
|
|
49
|
|
|
return $links; |
|
50
|
|
|
}); |
|
51
|
|
|
|
|
52
|
|
|
return $datatables->make(true); |
|
53
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return view('backend.product-amount-series.index')->with(array('product' => $product)); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function store(Request $request, $productId) |
|
60
|
|
|
{ |
|
61
|
|
|
$result = $this->productAmountSeries->create($request->all(), $productId); |
|
62
|
|
|
|
|
63
|
|
|
if (isset($result->id)) { |
|
64
|
|
|
Notification::success('The product amount series is updated.'); |
|
65
|
|
|
return redirect()->route('product.product-amount-series.index', $productId); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
if ($result) { |
|
69
|
|
|
foreach ($result->errors()->all() as $error) { |
|
70
|
|
|
\Notification::error($error); |
|
71
|
|
|
} |
|
72
|
|
|
} else { |
|
73
|
|
|
\Notification::error('amount series already exist'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return \redirect()->back()->withInput(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function edit(Request $request, $productId, $id) |
|
80
|
|
|
{ |
|
81
|
|
|
$product = ProductService::find($productId); |
|
82
|
|
|
$productAmountSeries = $this->productAmountSeries->find($id); |
|
83
|
|
|
|
|
84
|
|
|
return view('backend.product-amount-series.edit')->with( |
|
85
|
|
|
array( |
|
86
|
|
|
'productAmountSeries' => $productAmountSeries, |
|
87
|
|
|
'product' => $product, |
|
88
|
|
|
) |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function update(Request $request, $productId, $id) |
|
93
|
|
|
{ |
|
94
|
|
|
$result = $this->productAmountSeries->updateById($request->all(), $productId, $id); |
|
95
|
|
|
|
|
96
|
|
|
if (!$result->id) { |
|
|
|
|
|
|
97
|
|
|
return redirect()->back()->withInput()->withErrors($result->errors()->all()); |
|
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
Notification::success('The product amount series is updated.'); |
|
101
|
|
|
return redirect()->route('product.product-amount-series.index', $productId); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function destroy($productId, $id) |
|
105
|
|
|
{ |
|
106
|
|
|
$result = $this->productAmountSeries->destroy($id); |
|
107
|
|
|
|
|
108
|
|
|
if ($result) { |
|
109
|
|
|
Notification::success('The product amount series is deleted.'); |
|
110
|
|
|
return redirect()->route('product.product-amount-series.index', $productId); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
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