Conditions | 6 |
Paths | 12 |
Total Lines | 23 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php namespace Anomaly\Streams\Platform\Model\Command; |
||
36 | public function handle() |
||
37 | { |
||
38 | $action = $this->model->isForceDeleting() ? 'forceDelete' : 'delete'; |
||
39 | |||
40 | foreach ($this->model->getCascades() as $relation => $actions) { |
||
41 | if (in_array($action, $actions)) { |
||
42 | |||
43 | $relation = $this->model->{$relation}; |
||
44 | |||
45 | if ($relation instanceof EloquentModel) { |
||
46 | $relation->{$action}(); |
||
47 | } |
||
48 | |||
49 | if ($relation instanceof EloquentCollection) { |
||
50 | $relation->each( |
||
51 | function (EloquentModel $item) use ($action) { |
||
52 | $item->{$action}(); |
||
53 | } |
||
54 | ); |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 |