| Conditions | 6 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function handle() |
||
| 17 | { |
||
| 18 | $names = (array) $this->argument('name') ?: CRUD::query()->where('active', true)->pluck('name')->toArray(); |
||
| 19 | |||
| 20 | if($names == null) { |
||
| 21 | throw new CommandNotFoundException("There is no action in database"); |
||
| 22 | } |
||
| 23 | |||
| 24 | foreach ($names as $name) { |
||
| 25 | if (!in_array($name, CRUD::query()->pluck('name')->toArray())) { |
||
| 26 | $this->line("$name does not exist in config file"); |
||
| 27 | continue; |
||
| 28 | } |
||
| 29 | |||
| 30 | if ($this->askResult($name)) { |
||
| 31 | File::deleteDirectory(resource_path("/views/livewire/admin/$name")); |
||
| 32 | File::deleteDirectory(app_path("/Http/Livewire/Admin/" . ucfirst($name))); |
||
| 33 | File::delete(app_path("/CRUD/".ucfirst($name)."Component.php")); |
||
| 34 | $this->info("{$name} files were deleted, make sure you will delete {$name} value from actions in config"); |
||
| 35 | CRUD::query()->where('name', $name)->delete(); |
||
| 36 | } else { |
||
| 37 | $this->line("process for {$name} action was canceled."); |
||
| 38 | } |
||
| 53 |