LinkCommand.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Dcat\Admin\Console\Development;
  3. use Dcat\Admin\Admin;
  4. use Illuminate\Console\Command;
  5. class LinkCommand extends Command
  6. {
  7. /**
  8. * The console command signature.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'admin:dev:link';
  13. /**
  14. * Execute the console command.
  15. *
  16. * @return void
  17. */
  18. public function handle()
  19. {
  20. $this->linkAssets();
  21. $this->linkTests();
  22. }
  23. protected function linkTests()
  24. {
  25. }
  26. protected function linkAssets()
  27. {
  28. $basePath = Admin::asset()->getRealPath('@admin');
  29. $publicPath = public_path($basePath);
  30. if (! is_dir($publicPath.'/..')) {
  31. app('files')->makeDirectory($publicPath.'/..', 0755, true, true);
  32. }
  33. if (file_exists(public_path($publicPath))) {
  34. return $this->error("The \"{$basePath}\" directory already exists.");
  35. }
  36. $distPath = realpath(__DIR__ . '/../../../resources/dist');
  37. $this->laravel->make('files')->link(
  38. $distPath, $publicPath
  39. );
  40. $this->info("The [$basePath] directory has been linked.");
  41. }
  42. }