38 lines
952 B
PHP
Raw Normal View History

2022-12-10 18:29:42 +08:00
<?php
2022-12-14 19:25:52 +08:00
2022-12-10 18:29:42 +08:00
namespace Modules\Options\Repository;
use Catch\CatchAdmin;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class Components implements OptionInterface
{
/**
* @var array|string[]
*/
protected array $components = [
[
'label' => 'layout',
'value' => '/admin/layout/index.vue'
]
];
public function get(): array
{
if ($module = request()->get('module')) {
2022-12-18 22:44:58 +08:00
$components = File::glob(CatchAdmin::getModuleViewsPath($module).'*'.DIRECTORY_SEPARATOR.'*.vue');
2022-12-10 18:29:42 +08:00
foreach ($components as $component) {
$this->components[] = [
'label' => Str::of($component)->explode(DIRECTORY_SEPARATOR)->pop(2)->pop(),
'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/')
];
}
}
return $this->components;
}
}