4
0
Fork 0

调整添加扩展字段

master
vine_liutk 2022-08-09 10:01:43 +08:00
parent b5a22ce20e
commit d0b7c1397d
4 changed files with 16 additions and 4 deletions

View File

@ -1,15 +1,15 @@
{
"name": "peidikeji/article",
"alias": "article",
"description": "Description...",
"alias": "文章管理",
"description": "文章管理",
"type": "library",
"keywords": ["dcat-admin", "extension"],
"homepage": "https://github.com/peidikeji/article",
"license": "MIT",
"authors": [
{
"name": "your name",
"email": "your email"
"name": "liutk",
"email": "961510893@qq.com"
}
],
"require": {

View File

@ -15,6 +15,8 @@ class ArticleCategoryController extends AdminController
{
protected $translation = 'peidikeji.article::article-category';
protected $extDefaults = [];//例如:['key1'=>'']
public function grid(){
return Grid::make(new ArticleCategory(), function ($grid) {
$grid->disableRowSelector();
@ -75,6 +77,8 @@ class ArticleCategoryController extends AdminController
$form->text('remarks');
$form->hidden('level')->default(1);
$form->keyValue('ext', '扩展字段')->default($this->extDefaults)->setKeyLabel('键名')->setValueLabel('键值');
$controller = $this;
$form->saving(function (Form $form) use ($controller) {
if ($form->isCreating() && !$form->key) {

View File

@ -14,6 +14,8 @@ class ArticleController extends AdminController
{
protected $translation = 'peidikeji.article::article';
protected $extDefaults = [];//例如:['key1'=>'']
public function grid(){
return Grid::make(Article::with(['category', 'adminUser']), function ($grid) {
$grid->disableRowSelector();
@ -84,6 +86,8 @@ class ArticleController extends AdminController
$form->number('sort')->min(0)->default(0);
$form->text('remarks');
$form->keyValue('ext', '扩展字段')->default($this->extDefaults)->setKeyLabel('键名')->setValueLabel('键值');
$form->editor('content')->options([
'plugins' => [
'image',

View File

@ -26,6 +26,8 @@ class CreateArticleTable extends Migration
$table->unsignedInteger('sort')->default(0)->comment('排序 desc');
$table->string('remarks')->nullable()->comment('备注');
$table->text('ext')->nullable()->comment('扩展字段可用于SEO配置等');
$table->timestamps();
});
}
@ -48,6 +50,8 @@ class CreateArticleTable extends Migration
$table->unsignedTinyInteger('is_recommend')->default(0)->comment('推荐状态');
$table->unsignedTinyInteger('is_enable')->default(1)->comment('可用状态');
$table->text('ext')->nullable()->comment('扩展字段可用于SEO配置等');
$table->timestamps();
});
}