|
1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
use App\Http\Controllers\Controller; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* ContentController |
|
8
|
|
|
* |
|
9
|
|
|
* This is the controller of the contents of the shop |
|
10
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
|
11
|
|
|
* @version 0.1 |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
use Hideyo\Ecommerce\Framework\Services\Content\ContentFacade as ContentService; |
|
15
|
|
|
|
|
16
|
|
|
use Illuminate\Http\Request; |
|
17
|
|
|
use Notification; |
|
18
|
|
|
use Form; |
|
19
|
|
|
use Datatables; |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
class ContentController extends Controller |
|
22
|
|
|
{ |
|
23
|
|
|
public function index(Request $request) |
|
24
|
|
|
{ |
|
25
|
|
|
if ($request->wantsJson()) { |
|
26
|
|
|
|
|
27
|
|
|
$content = ContentService::getModel()->select( |
|
28
|
|
|
[ |
|
29
|
|
|
|
|
30
|
|
|
ContentService::getModel()->getTable().'.id', |
|
31
|
|
|
ContentService::getModel()->getTable().'.title', ContentService::getModel()->getTable().'.content_group_id', ContentService::getGroupModel()->getTable().'.title as contenttitle'] |
|
32
|
|
|
)->where(ContentService::getModel()->getTable().'.shop_id', '=', auth('hideyobackend')->user()->selected_shop_id) |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
->with(array('contentGroup')) ->leftJoin(ContentService::getGroupModel()->getTable(), ContentService::getGroupModel()->getTable().'.id', '=', ContentService::getModel()->getTable().'.content_group_id'); |
|
36
|
|
|
|
|
37
|
|
|
$datatables = Datatables::of($content) |
|
38
|
|
|
|
|
39
|
|
|
->filterColumn('title', function ($query, $keyword) { |
|
40
|
|
|
$query->whereRaw("content.title like ?", ["%{$keyword}%"]); |
|
41
|
|
|
}) |
|
42
|
|
|
->addColumn('contentgroup', function ($content) { |
|
43
|
|
|
return $content->contenttitle; |
|
44
|
|
|
}) |
|
45
|
|
|
->addColumn('action', function ($content) { |
|
46
|
|
|
$deleteLink = Form::deleteajax(url()->route('content.destroy', $content->id), 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
|
47
|
|
|
$links = '<a href="'.url()->route('content.edit', $content->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
|
|
|
return view('backend.content.index')->with('content', ContentService::selectAll()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function create() |
|
59
|
|
|
{ |
|
60
|
|
|
return view('backend.content.create')->with(array('groups' => ContentService::selectAllGroups()->pluck('title', 'id')->toArray())); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function store(Request $request) |
|
64
|
|
|
{ |
|
65
|
|
|
$result = ContentService::create($request->all()); |
|
66
|
|
|
return ContentService::notificationRedirect('content.index', $result, 'The content was inserted.'); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function edit($contentId) |
|
70
|
|
|
{ |
|
71
|
|
|
return view('backend.content.edit')->with(array('content' => ContentService::find($contentId), 'groups' => ContentService::selectAllGroups()->pluck('title', 'id')->toArray())); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function update(Request $request, $contentId) |
|
75
|
|
|
{ |
|
76
|
|
|
$result = ContentService::updateById($request->all(), $contentId); |
|
77
|
|
|
return ContentService::notificationRedirect('content.index', $result, 'The content was updated.'); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function destroy(Request $request, $contentId) |
|
81
|
|
|
{ |
|
82
|
|
|
$result = ContentService::destroy($contentId); |
|
83
|
|
|
|
|
84
|
|
|
if ($result) { |
|
85
|
|
|
Notification::success('The content was deleted.'); |
|
86
|
|
|
return redirect()->route('content.index'); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
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