thinkphp6 關聯模型如何查詢已經軟刪除的數據


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

就是移除使用軟刪除的意思。

既然移除了軟刪除,那么不管是不是軟刪除的數據,就都可以查詢出來了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM