2
2
3
3
namespace QCod \ImageUp ;
4
4
5
+ use Illuminate \Support \Arr ;
5
6
use Intervention \Image \Facades \Image ;
6
7
use Illuminate \Support \Facades \Storage ;
7
8
use Illuminate \Contracts \Validation \Factory ;
@@ -86,7 +87,7 @@ public function imageUrl($field = null)
86
87
$ attributeValue = $ this ->getOriginal ($ this ->uploadFieldName );
87
88
88
89
// check for placeholder defined in option
89
- $ placeholderImage = array_get ($ this ->uploadFieldOptions , 'placeholder ' );
90
+ $ placeholderImage = Arr:: get ($ this ->uploadFieldOptions , 'placeholder ' );
90
91
91
92
return (empty ($ attributeValue ) && $ placeholderImage )
92
93
? $ placeholderImage
@@ -186,8 +187,8 @@ public function resizeImage($imageFile, $imageFieldOptions)
186
187
}
187
188
188
189
// resize it according to options
189
- $ width = array_get ($ imageFieldOptions , 'width ' );
190
- $ height = array_get ($ imageFieldOptions , 'height ' );
190
+ $ width = Arr:: get ($ imageFieldOptions , 'width ' );
191
+ $ height = Arr:: get ($ imageFieldOptions , 'height ' );
191
192
$ cropHeight = empty ($ height ) ? $ width : $ height ;
192
193
$ crop = $ this ->getCropOption ($ imageFieldOptions );
193
194
@@ -284,8 +285,8 @@ public function getUploadFieldOptions($field = null)
284
285
);
285
286
}
286
287
287
- $ fieldKey = array_first (array_keys ($ imagesFields ));
288
- $ options = is_int ($ fieldKey ) ? [] : array_first ($ imagesFields );
288
+ $ fieldKey = Arr:: first (array_keys ($ imagesFields ));
289
+ $ options = is_int ($ fieldKey ) ? [] : Arr:: first ($ imagesFields );
289
290
290
291
return $ options ;
291
292
}
@@ -297,7 +298,7 @@ public function getUploadFieldOptions($field = null)
297
298
);
298
299
}
299
300
300
- return array_get ($ this ->getDefinedUploadFields (), $ field , []);
301
+ return Arr:: get ($ this ->getDefinedUploadFields (), $ field , []);
301
302
}
302
303
303
304
/**
@@ -339,7 +340,7 @@ public function getUploadFieldName($field = null)
339
340
}
340
341
341
342
$ imagesFields = $ this ->getDefinedUploadFields ();
342
- $ fieldKey = array_first (array_keys ($ imagesFields ));
343
+ $ fieldKey = Arr:: first (array_keys ($ imagesFields ));
343
344
344
345
// return first field name
345
346
return is_int ($ fieldKey )
@@ -379,7 +380,7 @@ public function hasFileField($field)
379
380
private function hasUploadField ($ field , $ definedField )
380
381
{
381
382
// check for string key
382
- if (array_has ($ definedField , $ field )) {
383
+ if (Arr:: has ($ definedField , $ field )) {
383
384
return true ;
384
385
}
385
386
@@ -436,7 +437,7 @@ private function deleteUploadedFile($filePath)
436
437
protected function getImageUploadPath ()
437
438
{
438
439
// check for disk option
439
- if ($ pathInOption = array_get ($ this ->uploadFieldOptions , 'path ' )) {
440
+ if ($ pathInOption = Arr:: get ($ this ->uploadFieldOptions , 'path ' )) {
440
441
return $ pathInOption ;
441
442
}
442
443
@@ -471,7 +472,7 @@ protected function getFileUploadPath($file)
471
472
protected function getImageUploadDisk ()
472
473
{
473
474
// check for disk option
474
- if ($ diskInOption = array_get ($ this ->uploadFieldOptions , 'disk ' )) {
475
+ if ($ diskInOption = Arr:: get ($ this ->uploadFieldOptions , 'disk ' )) {
475
476
return $ diskInOption ;
476
477
}
477
478
@@ -511,7 +512,7 @@ protected function getStorageDisk()
511
512
*/
512
513
protected function validateImage ($ file , $ fieldName , $ imageOptions )
513
514
{
514
- if ($ rules = array_get ($ imageOptions , 'rules ' )) {
515
+ if ($ rules = Arr:: get ($ imageOptions , 'rules ' )) {
515
516
$ this ->validationFactory ()->make (
516
517
[$ fieldName => $ file ],
517
518
[$ fieldName => $ rules ]
@@ -532,7 +533,7 @@ protected function saveImage($imageFile, $image)
532
533
// Trigger before save hook
533
534
$ this ->triggerBeforeSaveHook ($ image );
534
535
535
- $ imageQuality = array_get (
536
+ $ imageQuality = Arr:: get (
536
537
$ this ->uploadFieldOptions ,
537
538
'resize_image_quality ' ,
538
539
config ('imageup.resize_image_quality ' )
@@ -579,7 +580,7 @@ protected function updateModel($imagePath, $imageFieldName)
579
580
*/
580
581
protected function getCropOption ($ imageFieldOptions )
581
582
{
582
- $ crop = array_get ($ imageFieldOptions , 'crop ' , false );
583
+ $ crop = Arr:: get ($ imageFieldOptions , 'crop ' , false );
583
584
584
585
// check for crop override
585
586
if (isset ($ this ->cropCoordinates ) && count ($ this ->cropCoordinates ) == 2 ) {
@@ -609,17 +610,17 @@ protected function autoUpload()
609
610
{
610
611
foreach ($ this ->getDefinedUploadFields () as $ key => $ val ) {
611
612
$ field = is_int ($ key ) ? $ val : $ key ;
612
- $ options = array_wrap ($ val );
613
+ $ options = Arr:: wrap ($ val );
613
614
614
615
// check if global upload is allowed, then in override in option
615
- $ autoUploadAllowed = array_get ($ options , 'auto_upload ' , $ this ->canAutoUploadImages ());
616
+ $ autoUploadAllowed = Arr:: get ($ options , 'auto_upload ' , $ this ->canAutoUploadImages ());
616
617
617
618
if (!$ autoUploadAllowed ) {
618
619
continue ;
619
620
}
620
621
621
622
// get the input file name
622
- $ requestFileName = array_get ($ options , 'file_input ' , $ field );
623
+ $ requestFileName = Arr:: get ($ options , 'file_input ' , $ field );
623
624
624
625
// if request has the file upload it
625
626
if (request ()->hasFile ($ requestFileName )) {
@@ -652,7 +653,7 @@ protected function autoDeleteImage()
652
653
*/
653
654
protected function needResizing ($ imageFieldOptions )
654
655
{
655
- return array_has ($ imageFieldOptions , 'width ' ) || array_has ($ imageFieldOptions , 'height ' );
656
+ return Arr:: has ($ imageFieldOptions , 'width ' ) || Arr:: has ($ imageFieldOptions , 'height ' );
656
657
}
657
658
658
659
/**
0 commit comments