'Laravel Nova required image upload on every edit

I'm using laravel-nova and on one resource I'm using the Image field:

use Laravel\Nova\Fields\Image;

Image::make('Top Image', 'hero_image')
      ->help('Upload an image to display as hero')
      ->disk('local')
      ->maxWidth(400)
      ->prunable()
      ->rules('required')
      ->hideFromIndex(),

So far so good, but since it's required, I have to upload (the same) Image everytime I want to edit the resource which is a bit annoying and I don't want to make it not required.

So, is there a solution for this?



Solution 1:[1]

I sorted it out this way, I try to find if I already got the image saved on my model first then determine if I want to require it or not.

$imageRules =  $this->company_logo ? 'sometimes' : 'required';
    return [
        Image::make('Shop Logo', 'company_logo')
            ->disk('images')
           ->rules($imageRules, 'mimes:png')
            ->disableDownload()->deletable(false),

I hope this can help others.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 HAYTHEM