PermissionResourceCommand.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare(strict_types=1);
  3. namespace Modules\ManageApi\Commands;
  4. use Illuminate\Console\Command;
  5. use App\Repositories\Utils\AccessControllerListsRepository;
  6. /**
  7. * @Command
  8. */
  9. class PermissionResourceCommand extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'permission:resource';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $description = '更新后台权限资源表';
  23. private $aclRepo = null;
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * Execute the console command.
  35. *
  36. * @return mixed
  37. */
  38. public function handle()
  39. {
  40. $authConfig = config('manage_acl');
  41. $this->getAclRepo()->getController(
  42. $authConfig,
  43. base_path(). '/Modules/ManageApi/Controllers',
  44. 'Controller',
  45. 'Modules\ManageApi\Controllers'
  46. );
  47. $this->line('更新权限资源完毕,可以去表[permission_resource]查看确认', 'info');
  48. }
  49. /**
  50. * 获取ACL仓库
  51. * @return AccessControllerListsRepository|null
  52. */
  53. private function getAclRepo()
  54. {
  55. if (empty($this->aclRepo)) {
  56. $this->aclRepo = make(AccessControllerListsRepository::class);
  57. }
  58. return $this->aclRepo;
  59. }
  60. }