thinkphp6 关联模型如何查询已经软删除的数据

thinkphp6 关联模型如何查询已经软删除的数据

<?php
namespace appwomanmodel;

use thinkModel;
use thinkmodelconcernSoftDelete;

class Woman extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';

    // 模型初始化
    protected static function init()
    {
        //TODO:初始化内容
    }

    /**
     * 关联首次检查记录表模型
     * @return $this
     */
    public function womanFirstInspect()
    {
        return $this->hasOne(WomanFirstInspect::class)->removeOption('soft_delete');
    }

}

在关联模型的时候加上:

->removeOption('soft_delete');

就是移除使用软删除的意思。

既然移除了软删除,那么不管是不是软删除的数据,就都可以查询出来了。

原文地址:https://www.cnblogs.com/phpyangbo/p/13355196.html