Skip to content

Commit 6819aef

Browse files
authored
Merge pull request #36 from qcod/laravel-6
laravel 6 support
2 parents 675a99b + 1ea366d commit 6819aef

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- 7.1
54
- 7.2
65

76
before_script:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `laravel-imageup` will be documented in this file
44

5+
## 1.0.6 - 2019-09-06
6+
- Laravel 6 support
7+
58
## 1.0.5 - 2018-11-03
69
- Added support to upload non image file also
710
- Can disable/enable auto upload dynamiclly by calling `$model->disableAutoUpload()` and enable it back `$model->enableAutoUpload()`

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
],
2323
"require": {
2424
"php": ">=5.6.0",
25-
"laravel/framework": "~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0",
25+
"laravel/framework": "~5.4.0|~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0",
2626
"intervention/image": "^2.4"
2727
},
2828
"require-dev": {

src/HasImageUploads.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace QCod\ImageUp;
44

5+
use Illuminate\Support\Arr;
56
use Intervention\Image\Facades\Image;
67
use Illuminate\Support\Facades\Storage;
78
use Illuminate\Contracts\Validation\Factory;
@@ -86,7 +87,7 @@ public function imageUrl($field = null)
8687
$attributeValue = $this->getOriginal($this->uploadFieldName);
8788

8889
// check for placeholder defined in option
89-
$placeholderImage = array_get($this->uploadFieldOptions, 'placeholder');
90+
$placeholderImage = Arr::get($this->uploadFieldOptions, 'placeholder');
9091

9192
return (empty($attributeValue) && $placeholderImage)
9293
? $placeholderImage
@@ -186,8 +187,8 @@ public function resizeImage($imageFile, $imageFieldOptions)
186187
}
187188

188189
// 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');
191192
$cropHeight = empty($height) ? $width : $height;
192193
$crop = $this->getCropOption($imageFieldOptions);
193194

@@ -284,8 +285,8 @@ public function getUploadFieldOptions($field = null)
284285
);
285286
}
286287

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);
289290

290291
return $options;
291292
}
@@ -297,7 +298,7 @@ public function getUploadFieldOptions($field = null)
297298
);
298299
}
299300

300-
return array_get($this->getDefinedUploadFields(), $field, []);
301+
return Arr::get($this->getDefinedUploadFields(), $field, []);
301302
}
302303

303304
/**
@@ -339,7 +340,7 @@ public function getUploadFieldName($field = null)
339340
}
340341

341342
$imagesFields = $this->getDefinedUploadFields();
342-
$fieldKey = array_first(array_keys($imagesFields));
343+
$fieldKey = Arr::first(array_keys($imagesFields));
343344

344345
// return first field name
345346
return is_int($fieldKey)
@@ -379,7 +380,7 @@ public function hasFileField($field)
379380
private function hasUploadField($field, $definedField)
380381
{
381382
// check for string key
382-
if (array_has($definedField, $field)) {
383+
if (Arr::has($definedField, $field)) {
383384
return true;
384385
}
385386

@@ -436,7 +437,7 @@ private function deleteUploadedFile($filePath)
436437
protected function getImageUploadPath()
437438
{
438439
// check for disk option
439-
if ($pathInOption = array_get($this->uploadFieldOptions, 'path')) {
440+
if ($pathInOption = Arr::get($this->uploadFieldOptions, 'path')) {
440441
return $pathInOption;
441442
}
442443

@@ -471,7 +472,7 @@ protected function getFileUploadPath($file)
471472
protected function getImageUploadDisk()
472473
{
473474
// check for disk option
474-
if ($diskInOption = array_get($this->uploadFieldOptions, 'disk')) {
475+
if ($diskInOption = Arr::get($this->uploadFieldOptions, 'disk')) {
475476
return $diskInOption;
476477
}
477478

@@ -511,7 +512,7 @@ protected function getStorageDisk()
511512
*/
512513
protected function validateImage($file, $fieldName, $imageOptions)
513514
{
514-
if ($rules = array_get($imageOptions, 'rules')) {
515+
if ($rules = Arr::get($imageOptions, 'rules')) {
515516
$this->validationFactory()->make(
516517
[$fieldName => $file],
517518
[$fieldName => $rules]
@@ -532,7 +533,7 @@ protected function saveImage($imageFile, $image)
532533
// Trigger before save hook
533534
$this->triggerBeforeSaveHook($image);
534535

535-
$imageQuality = array_get(
536+
$imageQuality = Arr::get(
536537
$this->uploadFieldOptions,
537538
'resize_image_quality',
538539
config('imageup.resize_image_quality')
@@ -579,7 +580,7 @@ protected function updateModel($imagePath, $imageFieldName)
579580
*/
580581
protected function getCropOption($imageFieldOptions)
581582
{
582-
$crop = array_get($imageFieldOptions, 'crop', false);
583+
$crop = Arr::get($imageFieldOptions, 'crop', false);
583584

584585
// check for crop override
585586
if (isset($this->cropCoordinates) && count($this->cropCoordinates) == 2) {
@@ -609,17 +610,17 @@ protected function autoUpload()
609610
{
610611
foreach ($this->getDefinedUploadFields() as $key => $val) {
611612
$field = is_int($key) ? $val : $key;
612-
$options = array_wrap($val);
613+
$options = Arr::wrap($val);
613614

614615
// 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());
616617

617618
if (!$autoUploadAllowed) {
618619
continue;
619620
}
620621

621622
// get the input file name
622-
$requestFileName = array_get($options, 'file_input', $field);
623+
$requestFileName = Arr::get($options, 'file_input', $field);
623624

624625
// if request has the file upload it
625626
if (request()->hasFile($requestFileName)) {
@@ -652,7 +653,7 @@ protected function autoDeleteImage()
652653
*/
653654
protected function needResizing($imageFieldOptions)
654655
{
655-
return array_has($imageFieldOptions, 'width') || array_has($imageFieldOptions, 'height');
656+
return Arr::has($imageFieldOptions, 'width') || Arr::has($imageFieldOptions, 'height');
656657
}
657658

658659
/**

0 commit comments

Comments
 (0)