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

Cannot use a string as custom key for eloquent model in v2.x-dev #312

Open
chao opened this issue May 21, 2019 · 1 comment
Open

Cannot use a string as custom key for eloquent model in v2.x-dev #312

chao opened this issue May 21, 2019 · 1 comment

Comments

@chao
Copy link

chao commented May 21, 2019

It works just fine in version 1, but after I upgrade Laravel to 5.8 and Baum to v2.x-dev, I got a exception : Could not resolve target node. in Move.php L206.

Are we have to use integer as primary key in version 2?

@chao
Copy link
Author

chao commented May 21, 2019

Well, I made some modifications for resolveNode function as following, it works well.

protected function resolveNode($node)
    {
        if (method_exists($node, 'refresh') && is_callable([$node, 'refresh'])) {
            return $node->refresh();
        }

        if ($node instanceof \Illuminate\Database\Eloquent\Model) {
            return $node->newQuery()->find($node->getKey());
        }

        if (!empty($node)) {
           return $this->node->newQuery()->find($node);
        }
        throw new MoveNotPossibleException('Could not resolve target node.');
    }

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

1 participant