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)
136
136
// returns a result we can return that result, or we'll call the string events.
137
137
$ method = $ halt ? 'until ' : 'fire ' ;
138
138
139
- $ result = $ this ->fireCustomModelEvent ($ event , $ method );
139
+ $ result = $ this ->filterModelEventResults (
140
+ $ this ->fireCustomModelEvent ($ event , $ method )
141
+ );
140
142
141
143
if ($ result === false ) {
142
144
return false ;
143
145
}
144
146
145
- if (is_array ($ result )) {
146
- $ result = array_filter ($ result , function ($ response ) {
147
- return ! is_null ($ response );
148
- });
149
- }
150
-
151
147
return ! empty ($ result ) ? $ result : static ::$ dispatcher ->{$ method }(
152
148
"eloquent. {$ event }: " .static ::class, $ this
153
149
);
@@ -173,6 +169,23 @@ protected function fireCustomModelEvent($event, $method)
173
169
}
174
170
}
175
171
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
+
176
189
/**
177
190
* Register a saving model event with the dispatcher.
178
191
*
You can’t perform that action at this time.
0 commit comments