|
1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ContentGroupController |
|
5
|
|
|
* |
|
6
|
|
|
* This is the controller of the content groups of the shop |
|
7
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
|
8
|
|
|
* @version 0.1 |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
use App\Http\Controllers\Controller; |
|
12
|
|
|
use Illuminate\Http\Request; |
|
13
|
|
|
use DataTables; |
|
14
|
|
|
use Form; |
|
15
|
|
|
|
|
16
|
|
|
use Hideyo\Ecommerce\Framework\Services\Content\ContentFacade as ContentService; |
|
17
|
|
|
|
|
18
|
|
|
class ContentGroupController extends Controller |
|
19
|
|
|
{ |
|
20
|
|
|
public function index(Request $request) |
|
21
|
|
|
{ |
|
22
|
|
|
if ($request->wantsJson()) { |
|
23
|
|
|
|
|
24
|
|
|
$query = ContentService::getGroupModel() |
|
25
|
|
|
->select(['id', 'title']) |
|
26
|
|
|
->where('shop_id', '=', auth('hideyobackend')->user()->selected_shop_id); |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
$datatables = DataTables::of($query) |
|
29
|
|
|
->addColumn('action', function ($query) { |
|
30
|
|
|
$deleteLink = Form::deleteajax(url()->route('content-group.destroy', $query->id), 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
|
31
|
|
|
$links = '<a href="'.url()->route('content-group.edit', $query->id).'" class="btn btn-default btn-sm btn-success"><i class="entypo-pencil"></i>Edit</a> '.$deleteLink; |
|
32
|
|
|
|
|
33
|
|
|
return $links; |
|
34
|
|
|
}); |
|
35
|
|
|
|
|
36
|
|
|
return $datatables->make(true); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
return view('backend.content_group.index')->with('contentGroup', ContentService::selectAll()); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function create() |
|
43
|
|
|
{ |
|
44
|
|
|
return view('backend.content_group.create')->with(array()); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function store(Request $request) |
|
48
|
|
|
{ |
|
49
|
|
|
$result = ContentService::createGroup($request->all()); |
|
50
|
|
|
return ContentService::notificationRedirect('content-group.index', $result, 'The content group was inserted.'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function edit($contentGroupId) |
|
54
|
|
|
{ |
|
55
|
|
|
return view('backend.content_group.edit')->with(array('contentGroup' => ContentService::findGroup($contentGroupId))); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function update(Request $request, $contentGroupId) |
|
59
|
|
|
{ |
|
60
|
|
|
$result = ContentService::updateGroupById($request->all(), $contentGroupId); |
|
61
|
|
|
return ContentService::notificationRedirect('content-group.index', $result, 'The content group was updated.'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Remove the specified resource from storage |
|
66
|
|
|
* @param int $contentGroupId |
|
67
|
|
|
* @return Redirect |
|
68
|
|
|
*/ |
|
69
|
|
|
public function destroy($contentGroupId) |
|
70
|
|
|
{ |
|
71
|
|
|
$result = ContentService::destroyGroup($contentGroupId); |
|
72
|
|
|
|
|
73
|
|
|
if ($result) { |
|
74
|
|
|
flash('The content was deleted.'); |
|
75
|
|
|
return redirect()->route('content-group.index'); |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|