Skip to content

Commit

Permalink
pass original return value in the event
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Jan 30, 2023
1 parent 4ff3c18 commit b1df996
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Database/Traits/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,21 @@ protected function getValidationAttributes()
*
* Example usage from TranslatableBehavior class:
*
* $model->bindEvent('model.getValidationAttributes', function() {
* $model->bindEvent('model.getValidationAttributes', function ($attributes) {
* $locale = $this->translateContext();
* if ($locale !== $this->translatableDefault) {
* $attributes = $this->model->getAttributes();
* return array_merge($attributes, $this->getTranslateDirty($locale));
* }
* });
*
*/
if ($attributes = $this->fireEvent('model.getValidationAttributes', [], true)) {
return $attributes;

$attributes = $this->getAttributes();
if (($validationAttributes = $this->fireEvent('model.getValidationAttributes', [$attributes], true)) !== null) {
return $validationAttributes;
}

return $this->getAttributes();
return $attributes;
}

/**
Expand Down

0 comments on commit b1df996

Please sign in to comment.