add cms banners
This commit is contained in:
49
catch/cms/tables/Banners.php
Normal file
49
catch/cms/tables/Banners.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables;
|
||||
|
||||
use catcher\CatchTable;
|
||||
use catchAdmin\cms\tables\forms\Factory;
|
||||
use catcher\library\table\Actions;
|
||||
use catcher\library\table\HeaderItem;
|
||||
|
||||
class Banners extends CatchTable
|
||||
{
|
||||
public function table()
|
||||
{
|
||||
// TODO: Implement table() method.
|
||||
return $this->getTable('banners')
|
||||
->header([
|
||||
HeaderItem::label('编号')->prop('id')->width(50),
|
||||
|
||||
HeaderItem::label('分类')->prop('category'),
|
||||
|
||||
HeaderItem::label('标题')->prop('title'),
|
||||
|
||||
HeaderItem::label('图片')->prop('banner_img')->withPreviewComponent(),
|
||||
|
||||
HeaderItem::label('外链')->prop('link_to')->withUrlComponent(),
|
||||
|
||||
HeaderItem::label('创建者')->prop('creator'),
|
||||
|
||||
HeaderItem::label('创建时间')->prop('created_at'),
|
||||
|
||||
HeaderItem::label('操作')->actions([
|
||||
Actions::update(),
|
||||
Actions::delete()
|
||||
])
|
||||
])
|
||||
->withActions([
|
||||
Actions::create()
|
||||
])
|
||||
->withBind()
|
||||
->withApiRoute('cms/banners')
|
||||
->render();
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
// TODO: Implement form() method.
|
||||
return Factory::create('banners');
|
||||
}
|
||||
|
||||
}
|
38
catch/cms/tables/forms/Banners.php
Normal file
38
catch/cms/tables/forms/Banners.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace catchAdmin\cms\tables\forms;
|
||||
|
||||
use catchAdmin\cms\model\Category;
|
||||
use catcher\library\form\Form;
|
||||
|
||||
class Banners extends Form
|
||||
{
|
||||
public function fields(): array
|
||||
{
|
||||
$categories = Category::field(['id', 'name', 'parent_id'])->select()->toTree();
|
||||
|
||||
// TODO: Implement fields() method.
|
||||
return [
|
||||
self::cascader('category_id', '选择分类', [])
|
||||
->options($categories)
|
||||
->clearable(true)
|
||||
->filterable(true)
|
||||
->showAllLevels(false)
|
||||
->props([
|
||||
'props' => [
|
||||
'value' => 'id',
|
||||
'label' => 'name',
|
||||
'checkStrictly' => true
|
||||
],
|
||||
])->style(['width' => '100%'])
|
||||
->required(),
|
||||
|
||||
self::input('title', '标题')->placeholder('请输入标题')->required(),
|
||||
|
||||
self::image('图片', 'banner_img'),
|
||||
|
||||
self::input('link_to', '外链')->appendValidate([
|
||||
self::validateUrl()
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user