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
Eloquent\Model->getDirty() is type sensitive. Is this the behaviour we want? #1429
Comments
I think this has shifted back and forth several times. It seems like some people were changing |
Yeah, I can see a good reason for why you'd want to differentiate 0 and null. I wonder if there's any sense in having the INPUT class convert HTTP post and get numeric values to integer? Does that have any downsides? |
@chrisreiduk What if I posted a phone number "012-345 6789" or postcode "00123", how does this numeric values to integer handles it? // manual way would be something like
Input::replace(array('id' => intval(Input::get('id')))); |
@crynobone. Yeah that would break things; trimming off the leading zeros for starters. So not a good idea then. It's just a shame that PDO and other DB drivers return strings for integer fields. |
Yeah, t is hey. But at least you can use getter and setter mutators to prepare data for strict comparison. |
Maybe have protected $integers = array('id', 'customer_id' ... etc); and then logic within Eloquent\Model for automatic integer mutators like we have with the dates. Or anything that ends in '_id' or 'Id' could convert to/from integer? |
All it would really take on your model would be something like:
|
You don't want automatic, not for everybody, or are you just referring within your model?
|
Taylor's solution above into my BaseModel works for me! Thanks |
ChrisReid commentedMay 28, 2013
When a form is submitted, integers are presented as strings. When we resubmit the same form, $value !== $this->original[$key] so is classed as 'dirty' and rewritten to the database. I propose to change this to:
$value != $this->original[$key]
on line 2158. I would submit a patch but PR seems to be disabled.
Can anyone think of why it should be type sensitive?
The text was updated successfully, but these errors were encountered: