diff --git a/user_guide_src/source/changelogs/v4.3.0.rst b/user_guide_src/source/changelogs/v4.3.0.rst index 565a78e0127a..f45ef9a7ef86 100644 --- a/user_guide_src/source/changelogs/v4.3.0.rst +++ b/user_guide_src/source/changelogs/v4.3.0.rst @@ -59,6 +59,7 @@ Enhancements - Now **Encryption** can decrypt data encrypted with CI3's Encryption. See :ref:`encryption-compatible-with-ci3`. - Added method ``Timer::record()`` to measure performance in a callable. Also enhanced common function ``timer()`` to accept optional callable. - Now ``spark routes`` command shows route names. See :ref:`URI Routing `. +- Added new :ref:`entities-property-casting` class ``IntBoolCast`` for Entity. Changes ******* diff --git a/user_guide_src/source/models/entities.rst b/user_guide_src/source/models/entities.rst index 55187ae7a0ad..b4c705c4feae 100644 --- a/user_guide_src/source/models/entities.rst +++ b/user_guide_src/source/models/entities.rst @@ -187,6 +187,8 @@ current timezone, as set in **app/Config/App.php**: .. literalinclude:: entities/011.php +.. _entities-property-casting: + Property Casting ---------------- @@ -194,7 +196,7 @@ You can specify that properties in your Entity should be converted to common dat This option should be an array where the key is the name of the class property, and the value is the data type it should be cast to. Casting only affects when values are read. No conversions happen that affect the permanent value in either the entity or the database. Properties can be cast to any of the following data types: -**integer**, **float**, **double**, **string**, **boolean**, **object**, **array**, **datetime**, **timestamp**, and **uri**. +**integer**, **float**, **double**, **string**, **boolean**, **object**, **array**, **datetime**, **timestamp**, **uri** and **int-bool**. Add a question mark at the beginning of type to mark property as nullable, i.e., **?string**, **?integer**. For example, if you had a User entity with an ``is_banned`` property, you can cast it as a boolean: