Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:5.4from
tdondich:18353-Add-setKeyType-to-Eloquent-Model
Mar 16, 2017
Merged

[5.4] Add setKeyType() method to Eloquent abstract Model#18354
taylorotwell merged 2 commits into
laravel:5.4from
tdondich:18353-Add-setKeyType-to-Eloquent-Model

Conversation

@tdondich

@tdondich tdondich commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

Why are you changing the key type at run time?

@tdondich

Copy link
Copy Markdown
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