@@ -179,6 +179,16 @@ public function testCustomMorphPivotClassDetachAttributes()
179
179
180
180
$ project ->equipments ()->save ($ equipment );
181
181
$ equipment ->projects ()->sync ([]);
182
+
183
+ $ this ->assertEquals (
184
+ [PivotEventsTestProject::class, PivotEventsTestProject::class, PivotEventsTestProject::class, PivotEventsTestProject::class, PivotEventsTestProject::class, PivotEventsTestProject::class],
185
+ PivotEventsTestModelEquipment::$ eventsMorphClasses
186
+ );
187
+
188
+ $ this ->assertEquals (
189
+ ['equipmentable_type ' , 'equipmentable_type ' , 'equipmentable_type ' , 'equipmentable_type ' , 'equipmentable_type ' , 'equipmentable_type ' ],
190
+ PivotEventsTestModelEquipment::$ eventsMorphTypes
191
+ );
182
192
}
183
193
}
184
194
@@ -237,6 +247,55 @@ class PivotEventsTestModelEquipment extends MorphPivot
237
247
{
238
248
public $ table = 'equipmentables ' ;
239
249
250
+ public static $ eventsMorphClasses = [];
251
+
252
+ public static $ eventsMorphTypes = [];
253
+
254
+ public static function boot ()
255
+ {
256
+ parent ::boot ();
257
+
258
+ static ::creating (function ($ model ) {
259
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
260
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
261
+ });
262
+
263
+ static ::created (function ($ model ) {
264
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
265
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
266
+ });
267
+
268
+ static ::updating (function ($ model ) {
269
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
270
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
271
+ });
272
+
273
+ static ::updated (function ($ model ) {
274
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
275
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
276
+ });
277
+
278
+ static ::saving (function ($ model ) {
279
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
280
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
281
+ });
282
+
283
+ static ::saved (function ($ model ) {
284
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
285
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
286
+ });
287
+
288
+ static ::deleting (function ($ model ) {
289
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
290
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
291
+ });
292
+
293
+ static ::deleted (function ($ model ) {
294
+ static ::$ eventsMorphClasses [] = $ model ->morphClass ;
295
+ static ::$ eventsMorphTypes [] = $ model ->morphType ;
296
+ });
297
+ }
298
+
240
299
public function equipment ()
241
300
{
242
301
return $ this ->belongsTo (PivotEventsTestEquipment::class);
0 commit comments