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

ID::make() should use model's primary key #38

Closed
rcknr opened this issue Aug 23, 2018 · 4 comments
Closed

ID::make() should use model's primary key #38

rcknr opened this issue Aug 23, 2018 · 4 comments

Comments

@rcknr
Copy link

rcknr commented Aug 23, 2018

ID::make() assumes that primary key is id which often isn't the case. Why not default to Model::getModel()->getKeyName() instead?

@MattMangoni
Copy link

I wouldn't say 'often', but yeah, this is something to take into account :)

@devmsh
Copy link

devmsh commented Aug 27, 2018

What version you use?

public static function forModel($model)
    {
        return tap(static::make('ID', $model->getKeyName()))->resolve($model);
    }

ID currently use getKeyName as you mention

@davidhemphill
Copy link
Contributor

As @devmsh posted, the ID field uses the value from getKeyName().

@rcknr
Copy link
Author

rcknr commented Sep 11, 2018

For the reference, it should be used like so:

ID::forModel($this->model())

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

4 participants