|
9 | 9 |
|
10 | 10 | class GallerysController extends Controller
|
11 | 11 | {
|
| 12 | + const UPLOAD_PATH = 'gallerys/'; |
| 13 | + const UPLOAD_ROUTE = 'admin.gallerys.upload'; |
| 14 | + |
12 | 15 | /**
|
13 | 16 | * Display a listing of the resource.
|
14 | 17 | *
|
@@ -56,8 +59,8 @@ public function store(Request $request)
|
56 | 59 | $gallery->save();
|
57 | 60 |
|
58 | 61 | $user = \Auth::User();
|
59 |
| - $path_from = 'gallerys/temp-'.$user->id.'/'; |
60 |
| - $path_to = 'gallerys/'.$gallery->id; |
| 62 | + $path_from = self::UPLOAD_PATH.'temp-'.$user->id.'/'; |
| 63 | + $path_to = self::UPLOAD_PATH.$gallery->id; |
61 | 64 |
|
62 | 65 | if (\Storage::disk('uploads')->exists($path_from)) {
|
63 | 66 | \Storage::disk('uploads')->move($path_from, $path_to);
|
@@ -132,7 +135,7 @@ public function destroy(Request $request)
|
132 | 135 | // tem que ser um foreach porque é um array de galerias
|
133 | 136 | foreach ($request->gallerys as $id) {
|
134 | 137 | // Checamos se o diretório existe
|
135 |
| - $path = 'gallerys/'.$id; |
| 138 | + $path = self::UPLOAD_PATH.$id; |
136 | 139 |
|
137 | 140 | // Deletamos o diretório da imagem
|
138 | 141 | if (\Storage::disk('uploads')->exists($path)) {
|
@@ -160,21 +163,21 @@ public function upload(Request $request, $id = null)
|
160 | 163 | }
|
161 | 164 |
|
162 | 165 | $config = [
|
163 |
| - 'script_url' => '/admin/gallerys/upload/'.$path.'/', |
164 |
| - 'upload_dir' => base_path().'/public/uploads/gallerys/'.$path.'/', |
165 |
| - 'upload_url' => url('/').'/uploads/gallerys/'.$path.'/', |
| 166 | + 'script_url' => route(self::UPLOAD_ROUTE,$path), |
| 167 | + 'upload_dir' => base_path().'/public/uploads/'.self::UPLOAD_PATH.$path.'/', |
| 168 | + 'upload_url' => url('/').'/uploads/'.self::UPLOAD_PATH.$path.'/', |
166 | 169 | 'delete_type' => 'GET',
|
167 | 170 | ];
|
168 | 171 |
|
169 | 172 |
|
170 | 173 | // Deletamos a imagem por GET
|
171 | 174 | if (isset($request->file)) {
|
172 |
| - $file = 'gallerys/'.$path.'/'.$request->file; |
| 175 | + $file = self::UPLOAD_PATH.$path.'/'.$request->file; |
173 | 176 | if (\Storage::disk('uploads')->has($file)) {
|
174 | 177 | \Storage::disk('uploads')->delete($file);
|
175 | 178 | }
|
176 | 179 |
|
177 |
| - $thumb = 'gallerys/'.$path.'/thumbnail/'.$request->file; |
| 180 | + $thumb = self::UPLOAD_PATH.$path.'/thumbnail/'.$request->file; |
178 | 181 | if (\Storage::disk('uploads')->has($thumb)) {
|
179 | 182 | \Storage::disk('uploads')->delete($thumb);
|
180 | 183 | }
|
|
0 commit comments