Controllers.php 784 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Modules\Common\Repository\Options;
  3. use Catch\CatchAdmin;
  4. use Illuminate\Support\Facades\File;
  5. use Illuminate\Support\Str;
  6. class Controllers implements OptionInterface
  7. {
  8. public function get(): array
  9. {
  10. $controllers = [];
  11. if ($module = request()->get('module')) {
  12. $controllerFiles = File::glob(CatchAdmin::getModuleControllerPath($module).'*.php');
  13. foreach ($controllerFiles as $controllerFile) {
  14. $controllers[] = [
  15. 'label' => Str::of(File::name($controllerFile))->lcfirst()->remove('Controller'),
  16. 'value' => Str::of(File::name($controllerFile))->lcfirst()->remove('Controller'),
  17. ];
  18. }
  19. }
  20. return $controllers;
  21. }
  22. }