Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit e7c1659

Browse files
validating and validated events observable fix
The validating event works when bound in the boot() function with the following code. <?php class Record extends Ardent{ static public function boot(){ parent::boot(); self::validating(function($record){ // this always works }); } } The observable object binding of the validating event only works if the $observables property includes "validating" in its array and is subsequently returned in the array when calling getObservableEvents(). <?php class Record extends Ardent{ // only works if this is set public $observables = array('validating'); } class Observer { public function validating($model){ // works if $observables = array('validating'); } } Record::observe(new Observer); The getObservableEvents() needs to be extended in the Ardent class to work correctly.
1 parent e98ed2d commit e7c1659

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/LaravelBook/Ardent/Ardent.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,4 +862,15 @@ public function newQuery($excludeDeleted = true) {
862862

863863
return $builder;
864864
}
865+
866+
public function getObservableEvents(){
867+
return array_merge(
868+
array(
869+
'creating', 'created', 'updating', 'updated',
870+
'deleting', 'deleted', 'saving', 'saved',
871+
'restoring', 'restored', 'validating', 'validated'
872+
),
873+
$this->observables
874+
);
875+
}
865876
}

0 commit comments

Comments
 (0)