80 lines
2.8 KiB
PHP
80 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|
use Slowlyo\OwlAdmin\Renderers\TextControl;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use App\Services\Admin\ArticleCategoryService;
|
|
use App\Admin\Components;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ArticleCategoryController extends AdminController
|
|
{
|
|
protected string $serviceName = ArticleCategoryService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->loadDataOnce(true)
|
|
->footerToolbar([])
|
|
->headerToolbar([
|
|
$this->createButton(true),
|
|
amis('reload')->align('right'),
|
|
amis('filter-toggler')->align('right'),
|
|
])
|
|
->quickSaveItemApi(admin_url('quick-edit/article-categories/$id'))
|
|
->columns([
|
|
['name' => 'id', 'label' => __('article-category.id')],
|
|
['name' => 'name', 'label' => __('article-category.name')],
|
|
['name' => 'icon', 'label' => __('article-category.icon'), 'type' => 'image', 'width' => 60],
|
|
['name' => 'sort', 'label' => __('article-category.sort')],
|
|
['name' => 'is_enable', 'label' => __('article-category.is_enable'), 'type' => 'switch', 'quickEdit' => [
|
|
'type' => 'switch',
|
|
'mode' => 'inline',
|
|
'onText' => __('admin.switch.on'),
|
|
'offText' => __('admin.switch.off'),
|
|
'saveImmediately' => true,
|
|
]],
|
|
$this->rowActions(true),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->body([
|
|
TextControl::make()->name('name')->label('名称')->required(true),
|
|
amisMake()->ImageControl()->name('icon')->label('icon')->autoUpload(true),
|
|
Components::make()->parentControl(admin_url('api/article-categories/tree-list')),
|
|
Components::make()->sortControl(),
|
|
amisMake()->SwitchControl()->name('is_enable')->value(true)->label('显示'),
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
return $this->baseDetail()->body([
|
|
['name' => 'id', 'type' => 'static', 'label' => __('article-category.id')],
|
|
['name' => 'name', 'type' => 'static', 'label' => __('article-category.name')],
|
|
['name' => 'created_at', 'type' => 'static', 'label' => __('article-category.created_at')],
|
|
]);
|
|
}
|
|
|
|
public function getTreeList(Request $request)
|
|
{
|
|
return $this->service->getTree();
|
|
}
|
|
|
|
public function quickSave(Request $request)
|
|
{
|
|
logger('1', $request->all());
|
|
|
|
return $this->response()->success();
|
|
}
|
|
}
|