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

<?php
namespace app\woman\model;

use think\Model;
use think\model\concern\SoftDelete;

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');

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

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

相关文章:

  • 2022-12-23
  • 2021-10-19
  • 2022-02-08
  • 2021-12-05
  • 2022-01-21
  • 2021-07-28
  • 2022-12-23
  • 2022-02-16
猜你喜欢
  • 2021-07-21
  • 2021-11-13
  • 2021-06-24
  • 2022-01-08
  • 2022-01-16
  • 2021-06-15
  • 2022-02-05
相关资源
相似解决方案