outl1ne / nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.
MIT License
271 stars 98 forks source link

Deleting files does not remove them from disk #125

Closed jexme closed 1 year ago

jexme commented 2 years ago

Calling the deleteImage method does not delete files from disk. At the moment, the model is assigning $existingRow->value = null and that's it. It seems to me that it is worth adding the deletion of a file from the disk, at least to give such an opportunity by determining the config.

https://github.com/outl1ne/nova-settings/blob/3bc1dd6f714bfe31d0ff3baac6805d9387a343b6/src/Http/Controllers/SettingsController.php#L117

Tarpsvo commented 1 year ago

Thanks for reporting this! Fixed in version 5.0.3. ;)

holyboly commented 1 year ago

This actually does not work whenever you group the fields into Panels, e.g.:

Panel::make(__('CompanyInformation'), [
    Image::make(__('Logo'), 'company_logo')->prunable(),
]),

Because of SettingsController:118:

$field = collect(NovaSettings::getFields($pathName))->firstWhere('attribute', $fieldName);

firstWhere is actually looking in the panels array, not the fields array inside the panel.

Tarpsvo commented 1 year ago

@holyboly Fixed by @marttinnotta in version 5.1.0.