-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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.2] Adds idType to model in order to prevent assumptions about ids #13985
Changes from 2 commits
bf59491
dc1c587
199d3b6
5f2d357
c9a4fc4
81a8482
63957cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,13 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab | |
*/ | ||
public $incrementing = true; | ||
|
||
/** | ||
* Sets the type used by the ID. | ||
* | ||
* @var string | ||
*/ | ||
public $idType = 'int'; | ||
|
||
/** | ||
* Indicates if the model should be timestamped. | ||
* | ||
|
@@ -2401,6 +2408,29 @@ public function setIncrementing($value) | |
return $this; | ||
} | ||
|
||
/** | ||
* Get the type of the ID. | ||
* | ||
* @return string | ||
*/ | ||
public function getIdType() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we shouldn't have these getters and setters |
||
{ | ||
return $this->idType; | ||
} | ||
|
||
/** | ||
* Set ID type. | ||
* | ||
* @param string $value | ||
* @return $this | ||
*/ | ||
public function setIdType($value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove this |
||
{ | ||
$this->idType = $value; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Convert the model instance to JSON. | ||
* | ||
|
@@ -2763,7 +2793,7 @@ public function getCasts() | |
{ | ||
if ($this->getIncrementing()) { | ||
return array_merge([ | ||
$this->getKeyName() => 'int', | ||
$this->getKeyName() => $this->getIdType(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
], $this->casts); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make it clear that this property is ignored when incrementing is not enabled.