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.2] Adds idType to model in order to prevent assumptions about ids #13985

Merged
merged 7 commits into from
Jun 17, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public $incrementing = true;

/**
* Sets the type used by the ID.
Copy link
Member

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.

*
* @var string
*/
public $idType = 'int';

/**
* Indicates if the model should be timestamped.
*
Expand Down Expand Up @@ -2401,6 +2408,29 @@ public function setIncrementing($value)
return $this;
}

/**
* Get the type of the ID.
*
* @return string
*/
public function getIdType()
Copy link
Member

Choose a reason for hiding this comment

The 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)
Copy link
Member

Choose a reason for hiding this comment

The 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.
*
Expand Down Expand Up @@ -2763,7 +2793,7 @@ public function getCasts()
{
if ($this->getIncrementing()) {
return array_merge([
$this->getKeyName() => 'int',
$this->getKeyName() => $this->getIdType(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->$idType ;)

], $this->casts);
}

Expand Down