优化
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user