Total Complexity | 3 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | trait CascadeDelete |
||
6 | { |
||
7 | /** |
||
8 | * Boot the trait. |
||
9 | * |
||
10 | * Listen for the deleted event of a model, and run |
||
11 | * the delete operation for morphs configured relationship methods. |
||
12 | */ |
||
13 | protected static function bootCascadeDelete() |
||
19 | }); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Fetch methods name than must return a morph relation. |
||
24 | * |
||
25 | * @return string[] |
||
26 | */ |
||
27 | public function getCascadeDeleteMorph() |
||
28 | { |
||
29 | return (array) ($this->cascadeDeleteMorph ?? []); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Clean residual morph relation from a model. Return number |
||
34 | * of deleted rows. |
||
35 | * |
||
36 | * @param bool $dryRun |
||
37 | * @return int |
||
38 | */ |
||
39 | public function deleteMorphResidual(bool $dryRun = false) |
||
42 | } |
||
43 | } |
||
44 |