*/ class RemoveModuleCommand extends Command { /** * The name of command. * * @var string */ protected $signature = 'remove:module {name}'; /** * The description of command. * * @var string */ protected $description = 'init setting'; /** * 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'); try { if ($name) { $repositoriesPath = "app/Contracts/Repositories/{$name}"; $adminControllerPath = "app/Http/Controllers/Admin/{$name}"; $apiControllerPath = "app/Http/Controllers/Api/{$name}"; $jobPath = "app/Jobs/{$name}"; $criteriaPath = "app/Repositories/Criteria/{$name}"; $eloquentPath = "app/Repositories/Eloquent/{$name}"; $enumsPath = "app/Repositories/Enums/{$name}"; $modelsPath = "app/Repositories/Models/{$name}"; $presentersPath = "app/Repositories/Presenters/{$name}"; $transformersPath = "app/Repositories/Transformers/{$name}"; $validatorsPath = "app/Repositories/Validators/{$name}"; $servicesPath = "app/Services/{$name}"; $commandsPath = "app/Console/Commands/{$name}"; exec('rm -r ' . base_path($repositoriesPath)); exec('rm -r ' . base_path($adminControllerPath)); exec('rm -r ' . base_path($apiControllerPath)); exec('rm -r ' . base_path($jobPath)); exec('rm -r ' . base_path($criteriaPath)); exec('rm -r ' . base_path($eloquentPath)); exec('rm -r ' . base_path($enumsPath)); exec('rm -r ' . base_path($modelsPath)); exec('rm -r ' . base_path($presentersPath)); exec('rm -r ' . base_path($transformersPath)); exec('rm -r ' . base_path($validatorsPath)); exec('rm -r ' . base_path($servicesPath)); exec('rm -r ' . base_path($commandsPath)); $tables = js2php(php2js(DB::select('show tables'))); $tables = array_column($tables, 'Tables_in_' . env('DB_DATABASE')); foreach ($tables as $table) { $if = Str::is(strtolower($name) . '_*', $table); $this->line('删除数据库:' . $table); if ($if) { Schema::dropIfExists($table); } } $this->line('删除成功'); } } catch (\Exception $exception) { dd($exception); } $this->line('ok'); } }