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

[5.4] Add setKeyType() method to Eloquent abstract Model #18354

Merged
merged 2 commits into from
Mar 16, 2017
Merged

[5.4] Add setKeyType() method to Eloquent abstract Model #18354

merged 2 commits into from
Mar 16, 2017

Conversation

tdondich
Copy link
Contributor

@tdondich tdondich commented Mar 15, 2017

The Eloquent Model class has various public methods to set the protected properties used to match characteristics of the underlying table, such as table name, primary key and primary key type. Eloquent documentation states to overwrite these protected properties in classes that extends Model. However, there are public methods provided to overwrite these values during runtime which are extremely useful if you have Eloquent Models that need to operate on multiple tables. There is setTable and setKeyName and setIncrementing, however, there is no setKeyType method to change the primary key type.

@themsaid themsaid changed the title Add missing setKeyType method to Eloquent abstract Model. (#18353) [5.4] Add setKeyType() method to Eloquent abstract Model Mar 15, 2017
@taylorotwell
Copy link
Member

Why are you changing the key type at run time?

@tdondich
Copy link
Contributor Author

@taylorotwell For dynamic purposes. I may have a table that uses a guid for primary key, or a unique char string, etc. We use the dynamic setTable and setIncrementing, etc for this purpose as well. More detailed info is in ticket #18353.

@taylorotwell taylorotwell merged commit a72edde into laravel:5.4 Mar 16, 2017
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

Successfully merging this pull request may close these issues.

2 participants