Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive related resource doesn't allow edit or create #2426

Closed
preliot opened this issue Mar 11, 2020 · 4 comments
Closed

Recursive related resource doesn't allow edit or create #2426

preliot opened this issue Mar 11, 2020 · 4 comments

Comments

@preliot
Copy link

preliot commented Mar 11, 2020

Laravel Version: 5.8.37
Nova Version: 2.11.1
PHP Version: 7.2.19
Operating System and Version: Windows 10
Browser type and version: Chrome 79 64-bits

Description

I've got a resource with catalog products. Some of them are simple products (no issues) and some are variations with simple products as configurable options. All simple, configurable and configurable options are in the same table.

I'm using Eminiarts\Tabs\Tabs to display info in several tabs.

I can see my recursive related product variations. I'ts also possible to view or delete a product variation. But i can't create or update an existing related resource. Both actions result in a 404, see console output for details:

/nova-api/catalog-products/field/children:1 Failed to load resource: the server responded with a status of 404 (Not Found)
vendor.js?id=fdec6f749c878e3a3065:1 Error: Request failed with status code 404
    at FtD3.t.exports (vendor.js?id=fdec6f749c878e3a3065:1)
    at t.exports (vendor.js?id=fdec6f749c878e3a3065:1)
    at XMLHttpRequest.f.onreadystatechange (vendor.js?id=fdec6f749c878e3a3065:1)
Xt @ vendor.js?id=fdec6f749c878e3a3065:1
Ft @ vendor.js?id=fdec6f749c878e3a3065:1
Ht @ vendor.js?id=fdec6f749c878e3a3065:1
(anonymous) @ vendor.js?id=fdec6f749c878e3a3065:1
/nova-api/catalog-products/field/children:1 Failed to load resource: the server responded with a status of 404 (Not Found)
vendor.js?id=fdec6f749c878e3a3065:1 Error: Request failed with status code 404
    at FtD3.t.exports (vendor.js?id=fdec6f749c878e3a3065:1)
    at t.exports (vendor.js?id=fdec6f749c878e3a3065:1)
    at XMLHttpRequest.f.onreadystatechange (vendor.js?id=fdec6f749c878e3a3065:1)
Xt @ vendor.js?id=fdec6f749c878e3a3065:1

Model

class CatalogProduct extends Model
{
//..
   public function children(): ?Relations\HasMany
    {
        return $this->hasMany(CatalogProduct::class, 'parent', $this->getKeyName());
    }

   public function isConfigurable(): bool
    {
        return $this->type == ProductType::CONFIGURABLE;
    }
 //..
}

Nova resource

//..
 public function fields(Request $request): array
    {
        $fields = [];

        if($this->isConfigurable())
        {
            $fields[] = Fields\HasMany::make(ucfirst(__('configurableProducts')), 'children', CatalogProduct::class)
                ->singularLabel(__('configurableProduct'));
        }

        return $fields;
    }
@preliot
Copy link
Author

preliot commented Mar 11, 2020

The 404 originates from Laravel\Nova\Http\Controllers\FieldController.php, method show()

@davidhemphill
Copy link
Contributor

I'm sorry but we are unable to assist with issues involving a third-party package. If you can demonstrate the issue on a clean install of Nova, please open a new issue so we can debug it. Thanks!

@preliot
Copy link
Author

preliot commented Apr 8, 2020

No longer an issue after composer update.

@bhargavhauper
Copy link

orlyapps/nova-belongsto-depend#101 (comment)
the same issue on a package of "orlyapps/nova-belongsto-depend"
not working
laravel nova not given dependent dropdown?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants