diff --git a/app/admin/model/v1/VideoCategoryModel.php b/app/admin/model/v1/VideoCategoryModel.php index 0ad1941f..1f2c9571 100644 --- a/app/admin/model/v1/VideoCategoryModel.php +++ b/app/admin/model/v1/VideoCategoryModel.php @@ -4,6 +4,7 @@ declare (strict_types = 1); namespace app\admin\model\v1; use app\common\model\VideoCategoryBaseModel; +use think\model\concern\SoftDelete; /** * 视频分类模型 @@ -11,6 +12,13 @@ use app\common\model\VideoCategoryBaseModel; */ class VideoCategoryModel extends VideoCategoryBaseModel { + // 启用软件删除 + use SoftDelete; + // 软删除字段 + protected $deleteTime = 'deleted_at'; + // 自动写入时间格式 + protected $autoWriteTimestamp = 'datetime'; + // 关联视频模型 public function video() { diff --git a/app/common/model/VideoCategoryBaseModel.php b/app/common/model/VideoCategoryBaseModel.php index 79781b7c..61e9bed8 100644 --- a/app/common/model/VideoCategoryBaseModel.php +++ b/app/common/model/VideoCategoryBaseModel.php @@ -24,5 +24,6 @@ class VideoCategoryBaseModel extends BaseModel 'is_show' => 'int', 'created_at' => 'datetime', 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', ]; } diff --git a/database/migrations/20241220073105_create_video_category.php b/database/migrations/20241220073105_create_video_category.php index 65049a63..733bbb9c 100644 --- a/database/migrations/20241220073105_create_video_category.php +++ b/database/migrations/20241220073105_create_video_category.php @@ -34,6 +34,7 @@ class CreateVideoCategory extends Migrator ->addColumn('is_show', 'boolean', ['null' => false, 'default' => 1, 'comment' => '是否显示:1是,0否']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间']) + ->addColumn('deleted_at', 'timestamp', ['null' => true, 'default' => null, 'comment' => '删除时间']) ->create(); } }