feat: add uploader
This commit is contained in:
37
modules/Common/Repository/Options/Components.php
Normal file
37
modules/Common/Repository/Options/Components.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Common\Repository\Options;
|
||||
|
||||
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')) {
|
||||
$components = File::glob(CatchAdmin::getModuleViewsPath($module).'*'.DIRECTORY_SEPARATOR.'*.vue');
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
29
modules/Common/Repository/Options/Controllers.php
Normal file
29
modules/Common/Repository/Options/Controllers.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Common\Repository\Options;
|
||||
|
||||
use Catch\CatchAdmin;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Controllers implements OptionInterface
|
||||
{
|
||||
public function get(): array
|
||||
{
|
||||
$controllers = [];
|
||||
|
||||
if ($module = request()->get('module')) {
|
||||
$controllerFiles = File::glob(CatchAdmin::getModuleControllerPath($module).'*.php');
|
||||
|
||||
foreach ($controllerFiles as $controllerFile) {
|
||||
$controllers[] = [
|
||||
'label' => Str::of(File::name($controllerFile))->lcfirst()->remove('Controller'),
|
||||
|
||||
'value' => Str::of(File::name($controllerFile))->lcfirst()->remove('Controller'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
}
|
38
modules/Common/Repository/Options/DataRange.php
Normal file
38
modules/Common/Repository/Options/DataRange.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Common\Repository\Options;
|
||||
|
||||
use Modules\Permissions\Enums\DataRange as DataRangeEnum;
|
||||
|
||||
class DataRange implements OptionInterface
|
||||
{
|
||||
public function get(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'label' => DataRangeEnum::All_Data->name(),
|
||||
'value' => DataRangeEnum::All_Data->value()
|
||||
],
|
||||
|
||||
[
|
||||
'label' => DataRangeEnum::Personal_Choose->name(),
|
||||
'value' => DataRangeEnum::Personal_Choose->value()
|
||||
],
|
||||
|
||||
[
|
||||
'label' => DataRangeEnum::Personal_Data->name(),
|
||||
'value' => DataRangeEnum::Personal_Data->value()
|
||||
],
|
||||
|
||||
[
|
||||
'label' => DataRangeEnum::Department_Data->name(),
|
||||
'value' => DataRangeEnum::Department_Data->value()
|
||||
],
|
||||
|
||||
[
|
||||
'label' => DataRangeEnum::Department_DOWN_Data->name(),
|
||||
'value' => DataRangeEnum::Department_DOWN_Data->value()
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
28
modules/Common/Repository/Options/Factory.php
Normal file
28
modules/Common/Repository/Options/Factory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Common\Repository\Options;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Factory
|
||||
{
|
||||
/**
|
||||
* make
|
||||
* @param string $optionName
|
||||
* @return OptionInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function make(string $optionName): OptionInterface
|
||||
{
|
||||
$className = __NAMESPACE__.'\\'.Str::of($optionName)->ucfirst()->toString();
|
||||
|
||||
$class = new $className();
|
||||
|
||||
if (! $class instanceof OptionInterface) {
|
||||
throw new Exception('option must be implement [OptionInterface]');
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
}
|
25
modules/Common/Repository/Options/Modules.php
Normal file
25
modules/Common/Repository/Options/Modules.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Common\Repository\Options;
|
||||
|
||||
use Catch\Support\Module\ModuleRepository;
|
||||
|
||||
class Modules implements OptionInterface
|
||||
{
|
||||
public function get(): array
|
||||
{
|
||||
$modules = [];
|
||||
|
||||
app(ModuleRepository::class)->all([])
|
||||
|
||||
->each(function ($module) use (&$modules) {
|
||||
$modules[] = [
|
||||
'label' => $module['title'],
|
||||
|
||||
'value' => $module['name']
|
||||
];
|
||||
});
|
||||
|
||||
return $modules;
|
||||
}
|
||||
}
|
11
modules/Common/Repository/Options/OptionInterface.php
Normal file
11
modules/Common/Repository/Options/OptionInterface.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Common\Repository\Options;
|
||||
|
||||
interface OptionInterface
|
||||
{
|
||||
/**
|
||||
* @return array{label: string, value: string|number }
|
||||
*/
|
||||
public function get(): array;
|
||||
}
|
23
modules/Common/Repository/Options/Status.php
Normal file
23
modules/Common/Repository/Options/Status.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Common\Repository\Options;
|
||||
|
||||
use Catch\Enums\Status as StatusEnum;
|
||||
|
||||
class Status implements OptionInterface
|
||||
{
|
||||
public function get(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'label' => StatusEnum::Enable->name(),
|
||||
'value' => StatusEnum::Enable->value()
|
||||
],
|
||||
|
||||
[
|
||||
'label' => StatusEnum::Disable->name(),
|
||||
'value' => StatusEnum::Disable->value()
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user