|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Repositories; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Cache; |
|
6
|
|
|
use Adminetic\Website\Models\Admin\Popup; |
|
7
|
|
|
use Adminetic\Website\Http\Requests\PopupRequest; |
|
8
|
|
|
use Adminetic\Website\Contracts\PopupRepositoryInterface; |
|
9
|
|
|
use Intervention\Image\Facades\Image; |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class PopupRepository implements PopupRepositoryInterface |
|
12
|
|
|
{ |
|
13
|
|
|
// Popup Index |
|
14
|
|
|
public function indexPopup() |
|
15
|
|
|
{ |
|
16
|
|
|
$popups = config('adminetic.caching', true) |
|
17
|
|
|
? (Cache::has('popups') ? Cache::get('popups') : Cache::rememberForever('popups', function () { |
|
18
|
|
|
return Popup::latest()->get(); |
|
19
|
|
|
})) |
|
20
|
|
|
: Popup::latest()->get(); |
|
21
|
|
|
return compact('popups'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
// Popup Create |
|
25
|
|
|
public function createPopup() |
|
26
|
|
|
{ |
|
27
|
|
|
// |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
// Popup Store |
|
31
|
|
|
public function storePopup(PopupRequest $request) |
|
32
|
|
|
{ |
|
33
|
|
|
$popup = Popup::create($request->validated()); |
|
34
|
|
|
$this->uploadImage($popup); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
// Popup Show |
|
38
|
|
|
public function showPopup(Popup $popup) |
|
39
|
|
|
{ |
|
40
|
|
|
return compact('popup'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
// Popup Edit |
|
44
|
|
|
public function editPopup(Popup $popup) |
|
45
|
|
|
{ |
|
46
|
|
|
return compact('popup'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
// Popup Update |
|
50
|
|
|
public function updatePopup(PopupRequest $request, Popup $popup) |
|
51
|
|
|
{ |
|
52
|
|
|
$popup->update($request->validated()); |
|
53
|
|
|
$this->uploadImage($popup); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
// Popup Destroy |
|
57
|
|
|
public function destroyPopup(Popup $popup) |
|
58
|
|
|
{ |
|
59
|
|
|
isset($popup->image) ? deleteImage($popup->image) : ''; |
|
|
|
|
|
|
60
|
|
|
$popup->delete(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
protected function uploadImage(Popup $popup) |
|
64
|
|
|
{ |
|
65
|
|
|
if (request()->has('image')) { |
|
66
|
|
|
$popup->update([ |
|
67
|
|
|
'image' => request()->image->store('website/popup', 'public') |
|
68
|
|
|
]); |
|
69
|
|
|
if (request()->file('image')->getClientOriginalExtension() == 'gif') { |
|
70
|
|
|
$imageName = time() . '.' . request()->image->extension(); |
|
71
|
|
|
|
|
72
|
|
|
request()->image->move(public_path('website/popup'), $imageName); |
|
73
|
|
|
} else { |
|
74
|
|
|
$image = Image::make(request()->file('image')->getRealPath()); |
|
75
|
|
|
$image->save(public_path('storage/' . $popup->image)); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
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