Skip to content

Commit 012b007

Browse files
authored
Merge pull request #110 from systeminc/development
Development
2 parents 2118e58 + 62ceeed commit 012b007

31 files changed

+1096
-77
lines changed

src/Console/UpdateCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ public function handle()
4444

4545
foreach ($package_config as $key => $value) {
4646
if (!isset($client_config[$key])) {
47-
File::put(base_path('config/laravel-admin.php'), ("<?php \r\n\r\nreturn ".preg_replace(['/$([ ])/', '/[ ]([ ])/'], ' ', var_export($replaceConfig, true)).';'));
47+
File::put(base_path('config/laravel-admin.php'), ("<?php \r\n\r\nreturn ".preg_replace(['/$([ ])/', '/[ ]([ ])/'], ' ', var_export($replaceConfig, true)).';'));
4848
$this->info('Config file ("config/laravel-admin.php") is merged, please see changes for new feature');
4949
}
5050
}
5151

5252
$this->line('Updating Configuration Done!');
5353
$this->line('');
54+
$configureFolder = Artisan::call('storage:link', []);
5455
$this->line('***');
5556
$this->line('');
5657
$this->info('Successfully update!');

src/Http/Controllers/AdminController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ public function anyTinyImages(Request $request)
7777

7878
$directory = 'images/tiny/'.$page_name.'/'.$page_id;
7979

80-
if (!Storage::exists($directory)) {
81-
Storage::createDir($directory);
80+
if (!Storage::exists('public/'.$directory)) {
81+
Storage::createDir('public/'.$directory);
8282
}
83-
$images = Storage::files($directory);
83+
$images = Storage::files('public/'.$directory);
8484

8585
return view('admin::tiny-images', compact('page_id', 'page_name', 'editor_id', 'images', 'directory'));
8686
}
@@ -104,7 +104,7 @@ public function anyUploadTinyImage(Request $request)
104104

105105
$original_image = Image::make($file)->encode();
106106

107-
Storage::put($directory.'/'.$original, $original_image);
107+
Storage::put('public/'.$directory.'/'.$original, $original_image);
108108
}
109109
}
110110

src/Http/Controllers/GalleriesController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function getDelete($gallery_id)
129129
}
130130

131131
foreach ($gallery->images as $image) {
132-
Storage::delete($image->source, $image->thumb_source, $image->mobile_source);
132+
Storage::delete('public/'.$image->source, 'public/'.$image->thumb_source, 'public/'.$image->mobile_source);
133133

134134
$image->delete();
135135
}
@@ -210,7 +210,7 @@ public function getEditElement($element_id)
210210
{
211211
$element = GalleryElement::find($element_id);
212212

213-
$mime = empty($element->content) || $element->page_element_type_id !== 3 ? null : Storage::mimeType($element->content);
213+
$mime = empty($element->content) || $element->page_element_type_id !== 3 ? null : Storage::mimeType('public/'.$element->content);
214214

215215
return view('admin::galleries.elements.edit-element', compact('element', 'mime'));
216216
}
@@ -258,7 +258,7 @@ public function getDeleteElement(Request $request, $element_id)
258258
$image = GalleryImage::find($element->image_id);
259259

260260
if ($element->page_element_type_id == 3 && !empty($element->content)) {
261-
Storage::delete($element->content);
261+
Storage::delete('public/'.$element->content);
262262
}
263263

264264
$page_id = $element->page_id;
@@ -278,7 +278,7 @@ public function getDeleteElementFile($element_id)
278278
{
279279
$element = GalleryElement::find($element_id);
280280

281-
Storage::delete($element->content);
281+
Storage::delete('public/'.$element->content);
282282

283283
$element->content = null;
284284
$element->save();
@@ -304,7 +304,7 @@ private function uploadImages($images, $gallery_id, $image_id = false)
304304
$thumb = '/thumb/'.$gallery_id.'-'.$image_name.'.'.$image->getClientOriginalExtension();
305305
$mobile = '/mobile/'.$gallery_id.'-'.$image_name.'.'.$image->getClientOriginalExtension();
306306

307-
$original_path = storage_path('images/galleries'.$original);
307+
$original_path = storage_path('public/images/galleries'.$original);
308308

309309
$original_image = $this->resizeImage(1920, 1080, 'images/galleries/', 'images/galleries'.$original, $image);
310310
$thumb_image = $this->resizeImage(375, 200, 'images/galleries/thumb/', 'images/galleries'.$thumb, $image);
@@ -338,7 +338,7 @@ private function handleFileElement($file)
338338
if ($file && $file->isValid()) {
339339
$dirname = 'elements/'.$file->getClientOriginalName();
340340

341-
Storage::put($dirname, file_get_contents($file));
341+
Storage::put('public/'.$dirname, file_get_contents($file));
342342

343343
return $dirname;
344344
}

src/Http/Controllers/PagesController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function getEditElement($element_id)
218218
$keys = explode('.', $element->key);
219219
$key = $keys[1];
220220

221-
$mime = empty($element->content) || $element->page_element_type_id !== 3 ? null : Storage::mimeType($element->content);
221+
$mime = empty($element->content) || $element->page_element_type_id !== 3 ? null : Storage::mimeType('public/'.$element->content);
222222

223223
return view('admin::pages.edit-element', compact('element', 'mime', 'key'));
224224
}
@@ -234,7 +234,7 @@ public function getDeleteElementFile($element_id)
234234
{
235235
$element = PageElement::find($element_id);
236236

237-
Storage::delete($element->content);
237+
Storage::delete('public/'.$element->content);
238238

239239
$element->content = null;
240240
$element->save();
@@ -283,7 +283,7 @@ public function getDeleteElement(Request $request, $element_id)
283283
$element = PageElement::find($element_id);
284284

285285
if ($element->page_element_type_id == 3 && !empty($element->content)) {
286-
Storage::delete($element->content);
286+
Storage::delete('public/'.$element->content);
287287
}
288288

289289
$page_id = $element->page_id;
@@ -318,7 +318,7 @@ private function handleFileElement($file, $elements_prefix)
318318
if ($file && $file->isValid()) {
319319
$dirname = 'pages/'.$elements_prefix.'/'.$file->getClientOriginalName();
320320

321-
Storage::put($dirname, file_get_contents($file));
321+
Storage::put('public/'.$dirname, file_get_contents($file));
322322

323323
return $dirname;
324324
}

src/Http/Controllers/Places/LocationsController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ public function postUpdate(Request $request, $location_id)
119119
$location = Location::find($location_id);
120120
$location->fill($data);
121121

122+
$this->deleteImage($request, $location);
123+
122124
$location->image = $request->hasFile('image') ? $this->saveImage($request->file('image'), 'locations') : null;
123125
$location->thumb_image = $request->hasFile('thumb_image') ? $this->saveImage($request->file('thumb_image'), 'locations/thumb') : null;
124126
$location->marker_image = $request->hasFile('marker_image') ? $this->saveImage($request->file('marker_image'), 'locations/marker') : null;
125127

126128
$location->map_id = $request->map_id == 0 ? null : $request->map_id;
127129
$location->key = str_slug($request->key);
128130

129-
$this->deleteImage();
130-
131131
$location->save();
132132

133133
return back()->with('success', 'Saved successfully');
@@ -145,15 +145,15 @@ public function getDelete($location_id)
145145
$location = Location::find($location_id);
146146

147147
if (!empty($location->image)) {
148-
Storage::delete($location->image);
148+
Storage::delete('public/'.$location->image);
149149
}
150150

151151
if (!empty($location->thumb_image)) {
152-
Storage::delete($location->thumb_image);
152+
Storage::delete('public/'.$location->thumb_image);
153153
}
154154

155155
if (!empty($location->marker_image)) {
156-
Storage::delete($location->marker_image);
156+
Storage::delete('public/'.$location->marker_image);
157157
}
158158

159159
$location->delete();
@@ -164,20 +164,20 @@ public function getDelete($location_id)
164164
/**
165165
* Delete image from one location.
166166
*/
167-
private function deleteImage()
167+
private function deleteImage($request, $location)
168168
{
169169
if ($request->input('delete_image')) {
170-
Storage::exists($location->image) ? Storage::delete($location->image) : '';
170+
Storage::exists('public/'.$location->image) ? Storage::delete('public/'.$location->image) : '';
171171
$location->image = null;
172172
}
173173

174174
if ($request->input('delete_thumb_image')) {
175-
Storage::exists($location->thumb_image) ? Storage::delete($location->thumb_image) : '';
175+
Storage::exists('public/'.$location->thumb_image) ? Storage::delete('public/'.$location->thumb_image) : '';
176176
$location->thumb_image = null;
177177
}
178178

179179
if ($request->input('delete_marker_image')) {
180-
Storage::exists($location->marker_image) ? Storage::delete($location->marker_image) : '';
180+
Storage::exists('public/'.$location->marker_image) ? Storage::delete('public/'.$location->marker_image) : '';
181181
$location->marker_image = null;
182182
}
183183
}

src/Http/Controllers/ResourcesController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Http\Controllers\Controller;
66
use File;
7+
use Image;
78

89
class ResourcesController extends Controller
910
{
@@ -57,6 +58,12 @@ public function scripts($filename)
5758
*/
5859
public function images($filename)
5960
{
60-
return response()->file($this->image_path.$filename);
61+
$src = $this->image_path.$filename;
62+
63+
$cache_image = Image::cache(function ($image) use ($src) {
64+
return $image->make($src)->greyscale();
65+
}, 60);
66+
67+
return response()->make($cache_image, 200);
6168
}
6269
}

src/Http/Controllers/SettingsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function postUpdate(Request $request)
4949
$dirname = 'admin-panel/'.$file->getClientOriginalName();
5050

5151
Storage::deleteDirectory('admin-panel');
52-
Storage::put($dirname, file_get_contents($file));
52+
Storage::put('public/'.$dirname, file_get_contents($file));
5353

5454
$source = $dirname;
5555
}

src/Http/Controllers/Shop/CategoriesController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public function postSave(Request $request, $category_id)
8383
$category->thumb = $request->hasFile('thumb') ? $this->saveImage($request->file('thumb'), 'categories') : $category->thumb;
8484

8585
if ($request->input('delete_thumb')) {
86-
if (Storage::exists($category->thumb)) {
87-
Storage::delete($category->thumb);
86+
if (Storage::exists('public/'.$category->thumb)) {
87+
Storage::delete('public/'.$category->thumb);
8888
}
8989

9090
$category->thumb = null;
@@ -93,8 +93,8 @@ public function postSave(Request $request, $category_id)
9393
$category->image = $request->hasFile('image') ? $this->saveImage($request->file('image'), 'categories') : $category->image;
9494

9595
if ($request->input('delete_image')) {
96-
if (Storage::exists($category->image)) {
97-
Storage::delete($category->image);
96+
if (Storage::exists('public/'.$category->image)) {
97+
Storage::delete('public/'.$category->image);
9898
}
9999

100100
$category->image = null;

src/Http/Controllers/Shop/ProductsController.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function postSave(Request $request, $product_id)
7979
}
8080

8181
$product = Product::find($product_id);
82+
8283
$product->update($request->all());
8384

8485
if ($request->hasFile('thumb')) {
@@ -92,16 +93,16 @@ public function postSave(Request $request, $product_id)
9293
}
9394

9495
if (!empty($request->delete_thumb)) {
95-
if (Storage::exists($product->thumb)) {
96-
Storage::delete($product->thumb);
96+
if (Storage::exists('public/'.$product->thumb)) {
97+
Storage::delete('public/'.$product->thumb);
9798
}
9899

99100
$product->thumb = null;
100101
}
101102

102103
if (!empty($request->delete_image)) {
103-
if (Storage::exists($product->image)) {
104-
Storage::delete($product->image);
104+
if (Storage::exists('public/'.$product->image)) {
105+
Storage::delete('public/'.$product->image);
105106
}
106107

107108
$product->image = null;
@@ -131,11 +132,11 @@ public function getDelete(Request $request, $product_id)
131132
$gallery = Gallery::whereTitle($product->gallery->title)->first();
132133

133134
foreach ($gallery->images as $image) {
134-
Storage::delete($image->source, $image->thumb_source, $image->mobile_source);
135+
Storage::delete('public/'.$image->source, 'public/'.$image->thumb_source, 'public/'.$image->mobile_source);
135136

136137
$image->delete();
137138
}
138-
Storage::delete($product->pdf);
139+
Storage::delete('public/'.$product->pdf);
139140

140141
$gallery->delete();
141142
$product->delete();
@@ -264,8 +265,8 @@ public function postUpdateVariation(Request $request, $variation_id)
264265
}
265266

266267
if (!empty($request->delete_image)) {
267-
if (Storage::exists($variation->image)) {
268-
Storage::delete($variation->image);
268+
if (Storage::exists('public/'.$variation->image)) {
269+
Storage::delete('public/'.$variation->image);
269270
}
270271

271272
$variation->image = null;
@@ -281,8 +282,8 @@ public function getDeleteVariation($variation_id)
281282
$variation = ProductVariation::find($variation_id);
282283

283284
if (!empty($variation->image)) {
284-
if (Storage::exists($variation->image)) {
285-
Storage::delete($variation->image);
285+
if (Storage::exists('public/'.$variation->image)) {
286+
Storage::delete('public/'.$variation->image);
286287
}
287288
}
288289

src/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ public function variations()
6464

6565
public function getVariationsByGroup($group)
6666
{
67-
return $this->hasMany('SystemInc\LaravelAdmin\ProductVariation')->whereGroup($group)->orderBy('created_at', 'desc')->get();
67+
return $this->hasMany('SystemInc\LaravelAdmin\ProductVariation')->whereGroup($group)->get();
6868
}
6969
}

0 commit comments

Comments
 (0)