Skip to content

Commit

Permalink
docs: add user guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Aug 9, 2022
1 parent 076a542 commit dd077aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <routing-spark-routes>`.
- Added new :ref:`entities-property-casting` class ``IntBoolCast`` for Entity.

Changes
*******
Expand Down
4 changes: 3 additions & 1 deletion user_guide_src/source/models/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,16 @@ current timezone, as set in **app/Config/App.php**:

.. literalinclude:: entities/011.php

.. _entities-property-casting:

Property Casting
----------------

You can specify that properties in your Entity should be converted to common data types with the ``$casts`` property.
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:
Expand Down

0 comments on commit dd077aa

Please sign in to comment.