-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
- Laravel Version: 5.3.28
- PHP Version: 7.1.0
- Database Driver & Version: SQLite 3
Description:
I've a table with boolean column is_robot generated with a migration as $table->boolean('is_robot')->default(false);.
And in Database GUI, is declared as integer (SQLite connection).
The problem is when i want update an existed record with eloquent model (i use the $casts to convert is_robot as boolean):
Session {#630 ▼
...
#attributes: array:13 [▼
"id" => "4"
...
"is_robot" => false
...
]
#original: array:13 [▼
"id" => "4"
...
"is_robot" => "0"
...
]
...
}
This is after i
fill()theis_robotattribute withfalse(it was"0"on retrieve).
Steps To Reproduce:
So when i use fill method and check if the model was changed with isDirty():
$session->fill([
'is_robot' => false,
]);
if ($session->isDirty()) {
$session->save();
// Other stuff...
}The isDirty() method always return true when is_robot in the $original array equals to "0" (string zero) and in the $attributes array equals to false.
I think the getDirty() doesn't check if the attribute has a cast.
I didn't test this issue with a mysql database (for the time being)
Best regards,