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');
就是移除使用軟刪除的意思。
既然移除了軟刪除,那么不管是不是軟刪除的數據,就都可以查詢出來了。