UninstallCommand.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Dcat\Admin\Console;
  3. use Dcat\Admin\Admin;
  4. use Illuminate\Console\Command;
  5. class UninstallCommand extends Command
  6. {
  7. /**
  8. * The console command name.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'admin:uninstall';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'Uninstall the admin package';
  19. /**
  20. * Execute the console command.
  21. *
  22. * @return void
  23. */
  24. public function handle()
  25. {
  26. if (! $this->confirm('Are you sure to uninstall dcat-admin?')) {
  27. return;
  28. }
  29. $this->removeFilesAndDirectories();
  30. $this->line('<info>Uninstalling dcat-admin!</info>');
  31. }
  32. /**
  33. * Remove files and directories.
  34. *
  35. * @return void
  36. */
  37. protected function removeFilesAndDirectories()
  38. {
  39. $this->laravel['files']->deleteDirectory(config('admin.directory'));
  40. $this->laravel['files']->deleteDirectory(public_path(Admin::asset()->getRealPath('@extension')));
  41. $this->laravel['files']->deleteDirectory(public_path(Admin::asset()->getRealPath('@admin')));
  42. $this->laravel['files']->delete(config_path('admin.php'));
  43. }
  44. }