Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions en/orm/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,25 @@ Validation Errors

After you :ref:`save an entity <saving-entities>` any validation errors will be
stored on the entity itself. You can access any validation errors using the
``errors()`` method::
``getErrors()`` or ``getError()`` method::

// Get all the errors
$errors = $user->getErrors();
// Prior to 3.4.0
$errors = $user->errors();

// Get the errors for a single field.

$errors = $user->getError('password');
// Prior to 3.4.0
$errors = $user->errors('password');

The ``errors()`` method can also be used to set the errors on an entity, making
The ``setErrors()`` or ``setError()`` method can also be used to set the errors on an entity, making
it easier to test code that works with error messages::

$user->setError('password', ['Password is required']);
$user->setErrors(['pasword' => ['Password is required'], 'username' => ['Username is required']]);
// Prior to 3.4.0
$user->errors('password', ['Password is required.']);

.. _entities-mass-assignment:
Expand Down