laravel / nova-issues

554 stars 34 forks source link

Deleting file results in 500 server error #1936

Closed programmende closed 5 years ago

programmende commented 5 years ago

Description

If i use the following field, i recive an 500 server error when i try to deleting the file with the generated delete button from field.

URL: /nova/resources/products/50/edit?viaResource=&viaResourceId=&viaRelationship=

Field: Avatar::make('Photo')->disk('public')->deletable()->prunable(),

Error response:

{
   "message":"Method Illuminate\\Support\\Collection::findFieldByAttribute does not exist.",
   "exception":"BadMethodCallException",
   "file":"/home/forge/DOMAINFOLDER/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php",
   "line":104,
   "trace":[
      {
         "file":"/home/forge/DOMAINFOLDER/nova/src/Http/Controllers/FieldDestroyController.php",
         "line":29,
         "function":"__call",
         "class":"Illuminate\\Support\\Collection",
         "type":"->"
      },
      {
         "function":"handle",
         "class":"Laravel\\Nova\\Http\\Controllers\\FieldDestroyController",
         "type":"->"
      }
   ]
}
jbrooksuk commented 5 years ago

@programmende can you invite me too, please?

king724 commented 5 years ago

Similar to #1819

chinleung commented 5 years ago

I did an investigation and found out that the issue comes from Eminiarts\Tabs\TabsOnEdit.

The trait has a method which returns Illuminate\Support\Collection instead of a Laravel\Nova\Fields\FieldCollection:

/**
 * Resolve the update fields.
 *
 * @param  \Laravel\Nova\Http\Requests\NovaRequest $request
 * @return \Illuminate\Support\Collection
 */
public function updateFields(NovaRequest $request)
{
    return collect(
        [
            'Tabs' => [
                'component' => 'tabs',
                'fields'    => $this->removeNonUpdateFields($request, $this->resolveFields($request)),
                'panel'     => Panel::defaultNameForUpdate($request->newResource()),
            ],
        ]
    );
}

Hence the method findFieldByAttribute doesn't exist.

dkulyk commented 5 years ago

This has been fixed and will be included in the next release. 👍

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.