| Conditions | 2 |
| Paths | 7 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function handle($id) |
||
| 14 | { |
||
| 15 | try { |
||
| 16 | DB::beginTransaction(); |
||
| 17 | |||
| 18 | $module = Module::findOrFail($id); |
||
| 19 | |||
| 20 | Relation::deleteRelationsOf($module->getMorphClass(), $module->id); |
||
| 21 | |||
| 22 | // Mark the slug as deleted to avoid any conflict with newly created modules with the same slug. |
||
| 23 | $module->update([ |
||
| 24 | 'slug' => $module->slug . $this->appendDeleteMarker(), |
||
| 25 | ]); |
||
| 26 | |||
| 27 | $module->delete(); |
||
| 28 | |||
| 29 | DB::commit(); |
||
| 30 | } catch (\Throwable $e) { |
||
| 31 | DB::rollBack(); |
||
| 32 | throw $e; |
||
| 33 | } |
||
| 41 |