cms update

This commit is contained in:
JaguarJack
2021-05-23 20:35:21 +08:00
parent 5abc675e5d
commit 034705bb3d
8 changed files with 263 additions and 65 deletions

View File

@@ -2,31 +2,36 @@
namespace catchAdmin\cms\tables\forms;
use catchAdmin\cms\model\Tags;
use catcher\library\form\Form;
use catchAdmin\cms\model\Articles as Article;
use catchAdmin\cms\model\Category;
class Articles extends Form
class Articles extends BaseForm
{
protected $table = 'cms_articles';
public function fields(): array
{
$categories = Category::field(['id', 'name', 'parent_id'])->select()->toTree();
// TODO: Implement fields() method.
return [
self::input('title', '标题')->required()->maxlength(100)->col(12),
self::cascader('category_id', '选择分类')
->options(
Category::field(['id', 'name', 'parent_id'])->select()->toTree()
)
->col(12)
->props(self::props('name', 'id', [
'checkStrictly' => true
]))
->filterable(true)
self::cascader('category_id', '选择分类', [])
->options($categories)
->clearable(true)
->style(['width' => '100%'])
->filterable(true)
->showAllLevels(false)
->props([
'props' => [
'value' => 'id',
'label' => 'name',
'checkStrictly' => true
],
])->style(['width' => '100%'])
->required()->col(8),
self::input('keywords', '关键字')->col(12),
self::image('封面', 'cover')->col(12),

View File

@@ -4,6 +4,7 @@ namespace catchAdmin\cms\tables\forms;
use catchAdmin\cms\model\Category as CategoryModel;
use catchAdmin\cms\support\DynamicFormFields;
use catcher\library\form\Form;
use catcher\Utils;
abstract class BaseForm extends Form
{
@@ -14,7 +15,7 @@ abstract class BaseForm extends Form
$fields = parent::create(); // TODO: Change the autogenerated stub
if ($this->table) {
return array_merge($fields, (new DynamicFormFields())->build($this->table));
return array_merge($fields, (new DynamicFormFields())->build(Utils::tableWithPrefix($this->table)));
}
return $fields;

View File

@@ -46,7 +46,7 @@ class ModelUsedFields extends Form
*/
protected function getModelFields($tableName)
{
$fields = array_keys(Db::name($tableName)->getFields());
$fields = array_keys(Db::table($tableName)->getFields());
foreach ($fields as $k => $field) {
if ($field === app(Models::class)->getDeleteAtField()) {