Skip to content

Commit

Permalink
[ci skip] Add note on entity properties, closes codeigniter4#2317
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Aug 25, 2020
1 parent dfbab73 commit 6468057
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion user_guide_src/source/models/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ on your entities without worrying much about stray fields getting saved incorrec
$user->fill($data);
$userModel->save($user);

You can also pass the data in the constructor and the data will be passed through the `fill()` method during instantiation.
You can also pass the data in the constructor and the data will be passed through the ``fill()`` method during instantiation.

::

Expand All @@ -135,6 +135,14 @@ You can also pass the data in the constructor and the data will be passed throug
$user = new \App\Entities\User($data);
$userModel->save($user);

Bulk Accessing Properties
-------------------------

The Entity class has two methods to extract all available properties into an array: ``toArray()`` and ``toRawArray()``.
Using the raw version will bypass magic "getter" methods and casts. Both methods can take a boolean first parameter
to specify whether returned values should be filtered by those that have changed, and a boolean final parameter to
make the method recursive, in case of nested Entities.

Handling Business Logic
=======================

Expand Down

0 comments on commit 6468057

Please sign in to comment.