1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ExtraFieldController |
5
|
|
|
* |
6
|
|
|
* This is the controller of the product weight types of the shop |
7
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
8
|
|
|
* @version 0.1 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
use App\Http\Controllers\Controller; |
12
|
|
|
|
13
|
|
|
use Hideyo\Ecommerce\Framework\Services\ExtraField\ExtraFieldFacade as ExtraFieldService; |
14
|
|
|
use Hideyo\Ecommerce\Framework\Services\ProductCategory\ProductCategoryFacade as ProductCategoryService; |
15
|
|
|
|
16
|
|
|
use Illuminate\Http\Request; |
17
|
|
|
use Notification; |
18
|
|
|
use Datatables; |
|
|
|
|
19
|
|
|
use Form; |
20
|
|
|
|
21
|
|
|
class ExtraFieldController extends Controller |
22
|
|
|
{ |
23
|
|
|
public function index(Request $request) |
24
|
|
|
{ |
25
|
|
|
if ($request->wantsJson()) { |
26
|
|
|
|
27
|
|
|
$query = ExtraFieldService::getModel() |
28
|
|
|
->select(['id', 'all_products','title']) |
29
|
|
|
->where('shop_id', '=', auth('hideyobackend')->user()->selected_shop_id); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$datatables = Datatables::of($query) |
32
|
|
|
|
33
|
|
|
->addColumn('category', function ($query) { |
34
|
|
|
if ($query->categories) { |
35
|
|
|
$output = array(); |
36
|
|
|
foreach ($query->categories as $categorie) { |
37
|
|
|
$output[] = $categorie->title; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
return implode(' | ', $output); |
41
|
|
|
} |
42
|
|
|
}) |
43
|
|
|
|
44
|
|
|
->addColumn('action', function ($query) { |
45
|
|
|
$deleteLink = Form::deleteajax(url()->route('extra-field.destroy', $query->id), 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
46
|
|
|
$links = '<a href="'.url()->route('extra-field.values.index', $query->id).'" class="btn btn-default btn-sm btn-info"><i class="entypo-pencil"></i>'.$query->values->count().' values</a> |
47
|
|
|
<a href="'.url()->route('extra-field.edit', $query->id).'" class="btn btn-default btn-sm btn-success"><i class="entypo-pencil"></i>Edit</a> |
48
|
|
|
'.$deleteLink; |
49
|
|
|
|
50
|
|
|
return $links; |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
return $datatables->make(true); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return view('backend.extra-field.index')->with('extraField', ExtraFieldService::selectAll()); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function create() |
60
|
|
|
{ |
61
|
|
|
return view('backend.extra-field.create')->with(array('productCategories' => ProductCategoryService::selectAll()->pluck('title', 'id'))); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function store(Request $request) |
65
|
|
|
{ |
66
|
|
|
$result = ExtraFieldService::create($request->all()); |
67
|
|
|
return ExtraFieldService::notificationRedirect('extra-field.index', $result, 'The extra field was inserted.'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function edit($id) |
71
|
|
|
{ |
72
|
|
|
return view('backend.extra-field.edit')->with(array('extraField' => ExtraFieldService::find($id), 'productCategories' => ProductCategoryService::selectAll()->pluck('title', 'id'))); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function update(Request $request, $id) |
76
|
|
|
{ |
77
|
|
|
$result = ExtraFieldService::updateById($request->all(), $id); |
78
|
|
|
return ExtraFieldService::notificationRedirect('extra-field.index', $result, 'The extra field was updated.'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function destroy($id) |
82
|
|
|
{ |
83
|
|
|
$result = ExtraFieldService::destroy($id); |
84
|
|
|
|
85
|
|
|
if ($result) { |
86
|
|
|
Notification::success('Extra field was deleted.'); |
87
|
|
|
return redirect()->route('extra-field.index'); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
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