99 * with this source code in the file LICENSE.
1010 */
1111
12- namespace Overtrue \LaravelUEditor ;
12+ namespace Codingyu \LaravelUEditor ;
1313
14- use Illuminate \Contracts \Filesystem \Filesystem ;
14+ use Illuminate \Support \Arr ;
15+ use Illuminate \Support \Str ;
1516use Illuminate \Http \Request ;
1617use Illuminate \Support \Facades \Storage ;
18+ use Overtrue \LaravelUEditor \Events \Catched ;
1719use Overtrue \LaravelUEditor \Events \Uploaded ;
1820use Overtrue \LaravelUEditor \Events \Uploading ;
19- use Overtrue \ LaravelUEditor \ Events \ Catched ;
21+ use Illuminate \ Contracts \ Filesystem \ Filesystem ;
2022use Symfony \Component \HttpFoundation \File \UploadedFile ;
2123
2224/**
@@ -121,8 +123,8 @@ public function fetch(Request $request)
121123 }
122124
123125 $ response = [
124- 'state ' => count ($ list ) ? 'SUCCESS ' : 'ERROR ' ,
125- 'list ' => $ list
126+ 'state ' => count ($ list ) ? 'SUCCESS ' : 'ERROR ' ,
127+ 'list ' => $ list
126128 ];
127129
128130 return response ()->json ($ response );
@@ -267,8 +269,10 @@ protected function fileHasError(UploadedFile $file, array $config)
267269 $ error = $ file ->getError ();
268270 } elseif ($ file ->getSize () > $ config ['max_size ' ]) {
269271 $ error = 'upload.ERROR_SIZE_EXCEED ' ;
270- } elseif (!empty ($ config ['allow_files ' ]) &&
271- !in_array ('. ' .$ file ->getClientOriginalExtension (), $ config ['allow_files ' ])) {
272+ } elseif (
273+ !empty ($ config ['allow_files ' ]) &&
274+ !in_array ('. ' . $ file ->getClientOriginalExtension (), $ config ['allow_files ' ])
275+ ) {
272276 $ error = 'upload.ERROR_TYPE_NOT_ALLOWED ' ;
273277 }
274278
@@ -285,9 +289,9 @@ protected function fileHasError(UploadedFile $file, array $config)
285289 */
286290 protected function getFilename (UploadedFile $ file , array $ config )
287291 {
288- $ ext = '. ' . $ file ->getClientOriginalExtension ();
292+ $ ext = '. ' . $ file ->getClientOriginalExtension ();
289293
290- $ filename = config ('ueditor.hash_filename ' ) ? md5 ($ file ->getFilename ()). $ ext : $ file ->getClientOriginalName ();
294+ $ filename = config ('ueditor.hash_filename ' ) ? md5 ($ file ->getFilename ()) . $ ext : $ file ->getClientOriginalName ();
291295
292296 return $ this ->formatPath ($ config ['path_format ' ], $ filename );
293297 }
@@ -311,13 +315,13 @@ protected function getUploadConfig($action)
311315 $ config = [];
312316
313317 foreach ($ prefixes as $ prefix ) {
314- if ($ action == $ upload [$ prefix. 'ActionName ' ]) {
318+ if ($ action == $ upload [$ prefix . 'ActionName ' ]) {
315319 $ config = [
316- 'action ' => array_get ($ upload , $ prefix. 'ActionName ' ),
317- 'field_name ' => array_get ($ upload , $ prefix. 'FieldName ' ),
318- 'max_size ' => array_get ($ upload , $ prefix. 'MaxSize ' ),
319- 'allow_files ' => array_get ($ upload , $ prefix. 'AllowFiles ' , []),
320- 'path_format ' => array_get ($ upload , $ prefix. 'PathFormat ' ),
320+ 'action ' => Arr:: get ($ upload , $ prefix . 'ActionName ' ),
321+ 'field_name ' => Arr:: get ($ upload , $ prefix . 'FieldName ' ),
322+ 'max_size ' => Arr:: get ($ upload , $ prefix . 'MaxSize ' ),
323+ 'allow_files ' => Arr:: get ($ upload , $ prefix . 'AllowFiles ' , []),
324+ 'path_format ' => Arr:: get ($ upload , $ prefix . 'PathFormat ' ),
321325 ];
322326
323327 break ;
@@ -359,8 +363,8 @@ protected function formatPath($path, $filename)
359363 $ path = preg_replace ('/\{rand\:[\d]*\}/i ' , str_pad (mt_rand (0 , pow (10 , $ length ) - 1 ), $ length , '0 ' , STR_PAD_LEFT ), $ path );
360364 }
361365
362- if (!str_contains ($ path , $ filename )) {
363- $ path = str_finish ($ path , '/ ' ). $ filename ;
366+ if (!Str:: contains ($ path , $ filename )) {
367+ $ path = Str:: finish ($ path , '/ ' ) . $ filename ;
364368 }
365369
366370 return $ path ;
0 commit comments