From 0d54287c8f0a9c44462f12cf10be377219f6e110 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 12 Apr 2025 10:15:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E9=99=A4=E6=96=87?= =?UTF-8?q?=E7=AB=A0enabled=E5=AD=97=E6=AE=B5=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/Article.php | 4 +--- app/admin/model/v1/ArticleModel.php | 6 ------ app/common/model/ArticleBaseModel.php | 1 - database/migrations/20241220062631_create_article.php | 1 - 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/app/admin/controller/v1/Article.php b/app/admin/controller/v1/Article.php index 7da11d8b..a68edba9 100644 --- a/app/admin/controller/v1/Article.php +++ b/app/admin/controller/v1/Article.php @@ -207,7 +207,6 @@ class Article 'seo_title' => 'seo标题', 'seo_keywords' => 'seo关键词', 'seo_desc' => 'seo描述', - 'enabled' => '是否启用', 'release_time' => '发布时间', 'created_at' => '添加时间', 'updated_at' => '最后更新时间' @@ -229,8 +228,7 @@ class Article $data = ArticleModel::field([ '*', 'image', - 'CASE WHEN recommend = 1 THEN "是" ELSE "否" END' => 'recommend', - 'CASE WHEN enabled = 1 THEN "是" ELSE "否" END' => 'enabled', + 'CASE WHEN recommend = 1 THEN "是" ELSE "否" END' => 'recommend' ]) ->with('category', function($query) { return $query->field(['id', 'name']); diff --git a/app/admin/model/v1/ArticleModel.php b/app/admin/model/v1/ArticleModel.php index 21f87b41..9d20a662 100644 --- a/app/admin/model/v1/ArticleModel.php +++ b/app/admin/model/v1/ArticleModel.php @@ -94,10 +94,4 @@ class ArticleModel extends ArticleBaseModel } $query->where('category_id', '=', $value); } - - // 已启用的查询 - public function scopeEnabled($query) - { - $query->where('enabled', '=', 1); - } } diff --git a/app/common/model/ArticleBaseModel.php b/app/common/model/ArticleBaseModel.php index a6b23b11..f965e579 100644 --- a/app/common/model/ArticleBaseModel.php +++ b/app/common/model/ArticleBaseModel.php @@ -34,7 +34,6 @@ class ArticleBaseModel extends BaseModel 'seo_title' => 'string', 'seo_keywords' => 'string', 'seo_desc' => 'string', - 'enabled' => 'int', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', diff --git a/database/migrations/20241220062631_create_article.php b/database/migrations/20241220062631_create_article.php index c42cbac8..96c1233f 100644 --- a/database/migrations/20241220062631_create_article.php +++ b/database/migrations/20241220062631_create_article.php @@ -45,7 +45,6 @@ class CreateArticle extends Migrator ->addColumn('seo_title', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => 'SEO标题']) ->addColumn('seo_keywords', 'string', ['limit' => 512, 'null' => true, 'default' => null, 'comment' => 'SEO关键字']) ->addColumn('seo_desc', 'string', ['limit' => 512, 'null' => true, 'default' => null, 'comment' => 'SEO描述']) - ->addColumn('enabled', 'boolean', ['null' => false, 'default' => 1, 'comment' => '是否启用:1是,-1否']) ->addColumn('release_time', 'datetime', ['null' => true, 'default' => null, 'comment' => '发布时间']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])