File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed
src/Illuminate/Database/Eloquent/Concerns Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -136,18 +136,14 @@ protected function fireModelEvent($event, $halt = true)
136136 // returns a result we can return that result, or we'll call the string events.
137137 $ method = $ halt ? 'until ' : 'fire ' ;
138138
139- $ result = $ this ->fireCustomModelEvent ($ event , $ method );
139+ $ result = $ this ->filterModelEventResults (
140+ $ this ->fireCustomModelEvent ($ event , $ method )
141+ );
140142
141143 if ($ result === false ) {
142144 return false ;
143145 }
144146
145- if (is_array ($ result )) {
146- $ result = array_filter ($ result , function ($ response ) {
147- return ! is_null ($ response );
148- });
149- }
150-
151147 return ! empty ($ result ) ? $ result : static ::$ dispatcher ->{$ method }(
152148 "eloquent. {$ event }: " .static ::class, $ this
153149 );
@@ -173,6 +169,23 @@ protected function fireCustomModelEvent($event, $method)
173169 }
174170 }
175171
172+ /**
173+ * Filter the model event results.
174+ *
175+ * @param mixed $result
176+ * @return mixed
177+ */
178+ protected function filterModelEventResults ($ result )
179+ {
180+ if (is_array ($ result )) {
181+ $ result = array_filter ($ result , function ($ response ) {
182+ return ! is_null ($ response );
183+ });
184+ }
185+
186+ return $ result ;
187+ }
188+
176189 /**
177190 * Register a saving model event with the dispatcher.
178191 *
You can’t perform that action at this time.
0 commit comments