This commit is contained in:
Aether
2025-09-25 09:12:22 +08:00
parent f286e18e71
commit 25aa56439a
13 changed files with 171 additions and 167 deletions

View File

@@ -1,24 +1,26 @@
<?php
declare(strict_types=1);
namespace Aether\Traits;
use Hyperf\Database\Model\SoftDeletes;
/**
* 通用软删除Trait供需要软删除的模型使用
* 通用软删除Trait供需要软删除的模型使用.
*/
trait AetherSoftDelete
{
use SoftDeletes;
/**
* 初始化软删除相关配置自动隐藏deleted_at字段
* 初始化软删除相关配置自动隐藏deleted_at字段.
*/
protected function initializeAetherSoftDeletes(): void
{
// 自动将deleted_at添加到隐藏字段避免序列化时暴露
if (!in_array('deleted_at', $this->hidden, true)) {
if (! in_array('deleted_at', $this->hidden, true)) {
$this->hidden[] = 'deleted_at';
}
}
}
}