Skip to content

Commit

Permalink
修正软删除定义
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Aug 21, 2024
1 parent a59dff2 commit f533985
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
7 changes: 7 additions & 0 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab
*/
protected $lazyFields = [];

/**
* 软删除字段默认值
*
* @var mixed
*/
protected $defaultSoftDelete;

/**
* Db对象
*
Expand Down
15 changes: 4 additions & 11 deletions src/model/concern/SoftDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// +----------------------------------------------------------------------
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------
declare(strict_types=1);
declare (strict_types = 1);

namespace think\model\concern;

Expand All @@ -26,13 +26,6 @@
*/
trait SoftDelete
{
/**
* 软删除字段默认值
*
* @var mixed
*/
protected $defaultSoftDelete;

public function db($scope = []): Query
{
$query = parent::db($scope);
Expand Down Expand Up @@ -92,7 +85,7 @@ public function delete(): bool
return false;
}

$name = $this->getDeleteTimeField();
$name = $this->getDeleteTimeField();
$force = $this->isForce();

if ($name && !$force) {
Expand Down Expand Up @@ -152,7 +145,7 @@ public static function destroy($data, bool $force = false): bool
$query->where($data);
$data = [];
} elseif ($data instanceof \Closure) {
call_user_func_array($data, [&$query]);
call_user_func_array($data, [ &$query]);
$data = [];
}

Expand Down Expand Up @@ -206,7 +199,7 @@ public function restore(array $where = []): bool
*
* @return string|false
*/
public function getDeleteTimeField(bool $read = false): bool|string
public function getDeleteTimeField(bool $read = false): bool | string
{
$field = property_exists($this, 'deleteTime') && isset($this->deleteTime) ? $this->deleteTime : 'delete_time';

Expand Down

0 comments on commit f533985

Please sign in to comment.