|
1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ContentImageController |
|
5
|
|
|
* |
|
6
|
|
|
* This is the controller of the content images 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 Notification; |
|
14
|
|
|
use Datatables; |
|
|
|
|
|
|
15
|
|
|
use Form; |
|
16
|
|
|
|
|
17
|
|
|
use Hideyo\Ecommerce\Framework\Services\Content\ContentFacade as ContentService; |
|
18
|
|
|
|
|
19
|
|
|
class ContentImageController extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
public function index(Request $request, $contentId) |
|
22
|
|
|
{ |
|
23
|
|
|
$content = ContentService::find($contentId); |
|
24
|
|
|
if ($request->wantsJson()) { |
|
25
|
|
|
|
|
26
|
|
|
$image = ContentService::getImageModel()->select( |
|
27
|
|
|
[ |
|
28
|
|
|
|
|
29
|
|
|
'id', |
|
30
|
|
|
'file', 'content_id'] |
|
31
|
|
|
)->where('content_id', '=', $contentId); |
|
32
|
|
|
|
|
33
|
|
|
$datatables = Datatables::of($image) |
|
34
|
|
|
|
|
35
|
|
|
->addColumn('thumb', function ($image) use ($contentId) { |
|
|
|
|
|
|
36
|
|
|
return '<img src="/files/content/100x100/'.$image->content_id.'/'.$image->file.'" />'; |
|
37
|
|
|
}) |
|
38
|
|
|
->addColumn('action', function ($image) use ($contentId) { |
|
39
|
|
|
$deleteLink = Form::deleteajax('/admin/content/'.$contentId.'/images/'. $image->id, 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
|
40
|
|
|
$links = '<a href="/admin/content/'.$contentId.'/images/'.$image->id.'/edit" class="btn btn-default btn-sm btn-success"><i class="entypo-pencil"></i>Edit</a> '.$deleteLink; |
|
41
|
|
|
|
|
42
|
|
|
return $links; |
|
43
|
|
|
}); |
|
44
|
|
|
|
|
45
|
|
|
return $datatables->make(true); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return view('backend.content_image.index')->with(array('content' => $content)); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function create($contentId) |
|
52
|
|
|
{ |
|
53
|
|
|
$content = ContentService::find($contentId); |
|
54
|
|
|
return view('backend.content_image.create')->with(array('content' => $content)); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function store(Request $request, $contentId) |
|
58
|
|
|
{ |
|
59
|
|
|
$result = ContentService::createImage($request->all(), $contentId); |
|
60
|
|
|
return ContentService::notificationRedirect(array('content.{contentId}.images.index', $contentId), $result, 'The content image was inserted.'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function edit($contentId, $contentImageId) |
|
64
|
|
|
{ |
|
65
|
|
|
$content = ContentService::find($contentId); |
|
66
|
|
|
return view('backend.content_image.edit')->with(array('contentImage' => ContentService::findImage($contentImageId), 'content' => $content)); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function update(Request $request, $contentId, $contentImageId) |
|
70
|
|
|
{ |
|
71
|
|
|
$result = ContentService::updateImageById($request->all(), $contentId, $contentImageId); |
|
72
|
|
|
return ContentService::notificationRedirect(array('content.{contentId}.images.index', $contentId), $result, 'The content image was updated.'); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function destroy($contentId, $contentImageId) |
|
76
|
|
|
{ |
|
77
|
|
|
$result = ContentService::destroyImage($contentImageId); |
|
78
|
|
|
|
|
79
|
|
|
if ($result) { |
|
80
|
|
|
Notification::success('The file was deleted.'); |
|
81
|
|
|
return redirect()->route('content.{contentId}.images.index', $contentId); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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