ctessier / nova-advanced-image-field

🌄 📐 A Laravel Nova advanced image field with cropping and resizing using Vue Advanced Cropper and Intervention Image
https://novapackages.com/packages/ctessier/nova-advanced-image-field
MIT License
100 stars 26 forks source link

[BUGFIX] Dont call filesystem delete with null #74

Closed Woeler closed 2 years ago

Woeler commented 2 years ago

Applications using Laravel 9 will use FlySystem 3. The delete methods of FlySystem 3 no longer allow null as an argument. The argument must be a string.

See: https://github.com/thephpleague/flysystem/blob/3.x/src/Filesystem.php#L82

This pr simply surrounds the delete call with an if statement, so it isn't called when the given argument is null. This happens when using Laravel 9 while creating a new resource using the AdvancedImage field.

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Woeler commented 2 years ago

I am not sure if this is being maintained anymore. For those wanting a solution without editing the vendor code, create your own class that extends AdvancedImage and use it in instead. Class looks like this:

<?php

declare(strict_types=1);

namespace App\Nova\Fields;

use Laravel\Nova\Http\Requests\NovaRequest;

class AdvancedImage extends \Ctessier\NovaAdvancedImageField\AdvancedImage
{
    protected function fillAttribute(NovaRequest $request, $requestAttribute, $model, $attribute): void
    {
        $model->{$attribute} = $model->{$attribute} ?? '';

        parent::fillAttribute($request, $requestAttribute, $model, $attribute);
    }
}
ctessier commented 2 years ago

Hi @Woeler !

Thank you very much for your contribution 🎉

The pull request was merged and I just released v1.3.1!

Hope you have a great day! Clément

Woeler commented 2 years ago

Thanks! Fantastic.