*/ class RemoveModuleControllerCommand extends Command { /** * The name of command. * * @var string */ protected $signature = 'remove:module-controller {name} {key}'; /** * The description of command. * * @var string */ protected $description = '移除模块'; /** * The type of class being generated. * * @var string */ protected $type = 'setting'; /** * Execute the command. * * @return void * @see fire() */ public function handle() { $name = $this->argument('name'); $key = $this->argument('key'); try { if ($name) { $dirs[] = "app/Contracts/Repositories/{$name}"; $dirs[] = "app/Http/Controllers/Admin/{$name}"; $dirs[] = "app/Http/Controllers/Api/{$name}"; $dirs[] = "app/Jobs/{$name}"; $dirs[] = "app/Repositories/Criteria/{$name}"; $dirs[] = "app/Repositories/Eloquent/{$name}"; $dirs[] = "app/Repositories/Enums/{$name}"; $dirs[] = "app/Repositories/Models/{$name}"; $dirs[] = "app/Repositories/Presenters/{$name}"; $dirs[] = "app/Repositories/Transformers/{$name}"; $dirs[] = "app/Repositories/Validators/{$name}"; $dirs[] = "app/Services/{$name}"; $dirs[] = "app/Exports/{$name}"; $dirs[] = "app/Console/Commands/{$name}"; $dirs[] = "app/Http/Resources/{$name}"; foreach ($dirs as $dir) { $path = base_path($dir); if (!File::isDirectory($path)) continue; $files = scandir($path); $files = array_diff($files, array('.', '..')); foreach ($files as $file) { if (strpos($file, $key) === 0) { $this->line($dir . '/' . $file); exec('rm ' . $path . '/' . $file); } } } $this->line('删除成功'); } } catch (\Exception $exception) { dd($exception); } $this->line('ok'); } }