1 | <?php |
||
11 | trait CascadeSoftDeletes |
||
12 | { |
||
13 | /** |
||
14 | * Boot the trait. |
||
15 | * |
||
16 | * Listen for the deleting event of a soft deleting model, and run |
||
17 | * the delete operation for any configured relationship methods. |
||
18 | * |
||
19 | 10 | * @throws \LogicException |
|
20 | */ |
||
21 | protected static function bootCascadeSoftDeletes() |
||
29 | 9 | ||
30 | 3 | ||
31 | 3 | /** |
|
32 | 3 | * Validate that the calling model is correctly setup for cascading soft deletes. |
|
33 | 3 | * |
|
34 | 3 | * @throws \Iatstuti\Database\Support\CascadeSoftDeleteException |
|
35 | */ |
||
36 | protected function validateCascadingSoftDelete() |
||
46 | |||
47 | 6 | ||
48 | 9 | /** |
|
49 | 7 | * Run the cascading soft delete for this model. |
|
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | protected function runCascadingDeletes() |
||
59 | 10 | ||
60 | |||
61 | /** |
||
62 | * Cascade delete the given relationship on the given mode. |
||
63 | * |
||
64 | * @param string $relationship |
||
65 | * @return return |
||
|
|||
66 | */ |
||
67 | protected function cascadeSoftDeletes($relationship) |
||
75 | 9 | ||
76 | |||
77 | /** |
||
78 | * Determine if the current model implements soft deletes. |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | protected function implementsSoftDeletes() |
||
86 | 9 | ||
87 | |||
88 | /** |
||
89 | * Determine if the current model has any invalid cascading relationships defined. |
||
90 | * |
||
91 | * A relationship is considered invalid when the method does not exist, or the relationship |
||
92 | * method does not return an instance of Illuminate\Database\Eloquent\Relations\Relation. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | protected function hasInvalidCascadingRelationships() |
||
102 | |||
103 | |||
104 | /** |
||
105 | * Fetch the defined cascading soft deletes for this model. |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | protected function getCascadingDeletes() |
||
113 | |||
114 | |||
115 | /** |
||
116 | * For the cascading deletes defined on the model, return only those that are not null. |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | protected function getActiveCascadingDeletes() |
||
126 | } |
||
127 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.