|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Repositories; |
|
4
|
|
|
|
|
5
|
|
|
use Adminetic\Website\Contracts\GalleryRepositoryInterface; |
|
6
|
|
|
use Adminetic\Website\Http\Requests\GalleryRequest; |
|
7
|
|
|
use Adminetic\Website\Models\Admin\Gallery; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
use Illuminate\Support\Facades\Cache; |
|
10
|
|
|
use Intervention\Image\Facades\Image; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class GalleryRepository implements GalleryRepositoryInterface |
|
13
|
|
|
{ |
|
14
|
|
|
// Gallery Index |
|
15
|
|
|
public function indexGallery() |
|
16
|
|
|
{ |
|
17
|
|
|
$galleries = config('adminetic.caching', true) |
|
18
|
|
|
? (Cache::has('galleries') ? Cache::get('galleries') : Cache::rememberForever('galleries', function () { |
|
19
|
|
|
return Gallery::latest()->get(); |
|
20
|
|
|
})) |
|
21
|
|
|
: Gallery::latest()->get(); |
|
22
|
|
|
|
|
23
|
|
|
return compact('galleries'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
// Gallery Create |
|
27
|
|
|
public function createGallery() |
|
28
|
|
|
{ |
|
29
|
|
|
// |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
// Gallery Store |
|
33
|
|
|
public function storeGallery(GalleryRequest $request) |
|
34
|
|
|
{ |
|
35
|
|
|
$gallery = Gallery::create($request->validated()); |
|
36
|
|
|
$this->multipleImageUpload($gallery); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// Gallery Show |
|
40
|
|
|
public function showGallery(Gallery $gallery) |
|
41
|
|
|
{ |
|
42
|
|
|
return compact('gallery'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
// Gallery Edit |
|
46
|
|
|
public function editGallery(Gallery $gallery) |
|
47
|
|
|
{ |
|
48
|
|
|
return compact('gallery'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
// Gallery Update |
|
52
|
|
|
public function updateGallery(GalleryRequest $request, Gallery $gallery) |
|
53
|
|
|
{ |
|
54
|
|
|
$gallery->update($request->validated()); |
|
55
|
|
|
$this->multipleImageUpload($gallery); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
// Gallery Destroy |
|
59
|
|
|
public function destroyGallery(Gallery $gallery) |
|
60
|
|
|
{ |
|
61
|
|
|
if ($gallery->images->count() > 0) { |
|
62
|
|
|
foreach ($gallery->images as $image) { |
|
63
|
|
|
$image->hardDelete('image'); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
$gallery->delete(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
// multiple Image Upload |
|
71
|
|
|
protected function multipleImageUpload($gallery) |
|
72
|
|
|
{ |
|
73
|
|
|
if (request()->has('images')) { |
|
74
|
|
|
$imageRequest = app(\Adminetic\Website\Http\Requests\GalleryImageRequest::class, ['gallery' => $gallery]); |
|
75
|
|
|
$imageRequest->validated(); |
|
76
|
|
|
foreach (request()->images as $image) { |
|
77
|
|
|
$img = $gallery->images()->create([ |
|
78
|
|
|
'image' => $image, |
|
79
|
|
|
]); |
|
80
|
|
|
|
|
81
|
|
|
// Multi Image Upload With Thumbnail |
|
82
|
|
|
$multiple = [ |
|
83
|
|
|
'storage' => 'website/gallery/' . validImageFolder($gallery->name, 'gallery'), |
|
|
|
|
|
|
84
|
|
|
'width' => '600', |
|
85
|
|
|
'height' => '600', |
|
86
|
|
|
'quality' => '70', |
|
87
|
|
|
'image' => $image, |
|
88
|
|
|
'thumbnails' => [ |
|
89
|
|
|
[ |
|
90
|
|
|
'thumbnail-name' => 'small', |
|
91
|
|
|
'thumbnail-width' => '100', |
|
92
|
|
|
'thumbnail-height' => '100', |
|
93
|
|
|
'thumbnail-quality' => '30', |
|
94
|
|
|
], |
|
95
|
|
|
], |
|
96
|
|
|
]; |
|
97
|
|
|
$img->makeThumbnail('image', $multiple); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
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