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

Instance Exception when referenced Resource extends Laravel\Nova\Resource and not App\Nova\Resource #8

Closed
stiknoltz opened this issue May 15, 2019 · 2 comments

Comments

@stiknoltz
Copy link

First off thanks for creating this library. I've found it very useful.

I did notice the following which can occur in certain instances where you're including other Nova Resource generating Packages.

There is a type hint on line 48 of src/Http/Controllers/ImportController.php for an App\Nova\Resource class which fails if the Resource is from another vendor package which generally reference Laravel\Nova\Resource and not one created locally.

Since Laravel\Nova\Resource as NovaResource is already imported, the fix was was just a matter of changing the Resource type hint to NovaResource

I think #7 might be related to this issue.

@stiknoltz
Copy link
Author

Wasn't sure of the best way to provide this, but here's a diff of the proposed solution:

index 2bad80b..1d19f00 100644
--- a/src/Http/Controllers/ImportController.php
+++ b/src/Http/Controllers/ImportController.php
@@ -45,7 +45,7 @@ class ImportController
             $model = $resource::$model;
 
             return new $resource(new $model);
-        })->mapWithKeys(function (Resource $resource) use ($request) {
+        })->mapWithKeys(function (NovaResource $resource) use ($request) {
             return [$resource->uriKey() => $resource->creationFields($request)];
         });```

@simonhamp
Copy link
Owner

@stiknoltz I've just released this fix. Could you update your version and let me know if it's working for you?

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

2 participants