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

On dragable sort receive error - can't get model of null #92

Closed
chiz-developer opened this issue May 6, 2021 · 13 comments
Closed

On dragable sort receive error - can't get model of null #92

chiz-developer opened this issue May 6, 2021 · 13 comments

Comments

@chiz-developer
Copy link

Solved by providing viaResourceId to findResourceOrFail
Can you fix this?
image

@chiz-developer
Copy link
Author

$validationResult is null here
image

@Tarpsvo
Copy link
Collaborator

Tarpsvo commented May 7, 2021

I need to know more about your setup. What relationship are you using, what config etc?

@chiz-developer
Copy link
Author

chiz-developer commented May 7, 2021

Laravel Framework 7.29.3
Nova 3

HasMany relation

it works if i click on arrows like move to start / end, but doesn't work on drag.

on click move to end button - i have resourceId
image

on drag-drop ording - no resource id
image

Model
image

Resource
image

@Tarpsvo
Copy link
Collaborator

Tarpsvo commented May 7, 2021

Solved by providing viaResourceId to findResourceOrFail
Can you fix this?
image

That's weird, it shouldn't fix it, as resourceId is null for that reorder request.

Can you see what exception you have on line 25? Ie:

        try {
            if ($resource === null) {
                $resource = isset($request->resourceId) ? $request->findResourceOrFail() : $request->newResource();
            }
        } catch (\Exception $e) {
            throw $e;
            // return null;
        }

I honestly can't seem to reproduce this error.

@Tarpsvo
Copy link
Collaborator

Tarpsvo commented May 7, 2021

That's the error thrown when $validationResult is null, what about the error at HasSortableRows.php at line 25? Thanks!

@chiz-developer
Copy link
Author

message: "No query results for model [App\Models\SegmentationAnswer]."

@Tarpsvo
Copy link
Collaborator

Tarpsvo commented May 7, 2021

That's really weird. But if resourceId is null, why does it pass through isset($request->resourceId) check?

@chiz-developer
Copy link
Author

maybe because there is check for isset, not for is_null?

@Tarpsvo
Copy link
Collaborator

Tarpsvo commented May 7, 2021

isset also returns false for null. Can you check what the $request->resourceId value is there? ie use dd($request->resourceId). Thank you!

@chiz-developer
Copy link
Author

image
image
image

@chiz-developer
Copy link
Author

chiz-developer commented May 7, 2021

so on this way it works fine
image

@Tarpsvo
Copy link
Collaborator

Tarpsvo commented May 7, 2021

Ah interesting, so on the server, it somehow becomes an empty string. I have no idea how that happens though.

I replaced the isset() with !empty() which also checks for 0 and '' and released version 2.3.1 with the fix. Thanks a ton for your help! Good luck!

@Tarpsvo Tarpsvo closed this as completed May 7, 2021
@chiz-developer
Copy link
Author

thank you too!

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