71 lines
3.9 KiB
PHP
71 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use Slowlyo\OwlAdmin\Renderers\{Form, Page};
|
|
use Slowlyo\OwlAdmin\Renderers\{Component, Button, TableColumn, TextControl, SelectControl, DateTimeControl, SwitchControl, Tabs, Tab, Status, Html};
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use App\Services\Admin\AdminNoticeService;
|
|
use App\Admin\Components;
|
|
|
|
class AdminNoticeController extends AdminController
|
|
{
|
|
protected string $serviceName = AdminNoticeService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->headerToolbar([
|
|
$this->createButton(true, 'lg'),
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->filter($this->baseFilter()->actions([])->body([
|
|
TextControl::make()->name('title')->label(__('admin-notice.title'))->size('md'),
|
|
Button::make()->label(__('admin.reset'))->actionType('clear-and-submit'),
|
|
Component::make()->setType('submit')->label(__('admin.search'))->level('primary'),
|
|
]))
|
|
->quickSaveItemApi(admin_url('quick-edit/admin-notices/$id'))
|
|
->columns([
|
|
TableColumn::make()->name('id')->label(__('admin-notice.id')),
|
|
TableColumn::make()->name('title')->label(__('admin-notice.title')),
|
|
TableColumn::make()->name('article.title')->label(__('admin-notice.article_id')),
|
|
TableColumn::make()->name('is_enable')->type('switch')->label(__('admin-notice.is_enable'))->quickEdit(SwitchControl::make()->saveImmediately(true)->mode('inline')),
|
|
TableColumn::make()->name('sort')->label(__('admin-notice.sort'))->align('center')->quickEdit(Components::make()->sortControl('sort', __('admin-notice.sort'))->saveImmediately(true)),
|
|
TableColumn::make()->name('published_at')->label(__('admin-notice.published_at')),
|
|
$this->rowActions(true, 'lg'),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->title('')->body([
|
|
TextControl::make()->name('title')->label(__('admin-notice.title'))->required(true),
|
|
SelectControl::make()->name('article_id')->label(__('admin-notice.article_id'))->source(admin_url('api/articles/options')),
|
|
Components::make()->sortControl('sort', __('admin-notice.sort')),
|
|
DateTimeControl::make()->name('published_at')->label(__('admin-notice.published_at'))->value(now())->format('YYYY-MM-DD HH:mm:ss')->description('*不填写则默认为创建时间'),
|
|
SwitchControl::make()->name('is_enable')->label(__('admin-notice.is_enable'))->value(true),
|
|
Components::make()->fuEditorControl('content', __('admin-notice.content'))
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
return $this->baseDetail()->title('')->body([
|
|
TextControl::make()->static(true)->name('id')->label(__('admin-notice.id')),
|
|
TextControl::make()->static(true)->name('title')->label(__('admin-notice.title')),
|
|
TextControl::make()->static(true)->name('article.title')->label(__('admin-notice.article_id')),
|
|
TextControl::make()->static(true)->name('sort')->label(__('admin-notice.sort')),
|
|
TextControl::make()->name('is_enable')->label(__('admin-notice.is_enable'))->static(true)->staticSchema(Status::make()->source([
|
|
['label' => '不显示', 'icon' => 'fa fa-close', 'color' => '#cc292e'],
|
|
['label' => '显示', 'icon' => 'fa fa-check', 'color' => '#30bf13'],
|
|
])),
|
|
TextControl::make()->static(true)->name('published_at')->label(__('admin-notice.published_at')),
|
|
TextControl::make()->static(true)->name('created_at')->label(__('admin-notice.created_at')),
|
|
Components::make()->fuEditorControl('content', __('admin-notice.content'))->static(true),
|
|
]);
|
|
}
|
|
}
|