tp5模型里面定義了軟刪除,在定義關(guān)聯(lián)$order = Order::get(10);
$order->user //獲取訂單對應(yīng)的用戶//在模型中定義public function user (){ return $this-hasOne('user','id','user_id');
}這樣查詢出來的用戶如果被刪除 數(shù)據(jù)表字段中的delete_time 不是null 就不會顯示啦如何讓關(guān)聯(lián)方法查詢出來的是全部數(shù)據(jù) 包括軟刪除的數(shù)據(jù)下面這種寫法行不通... 還是說我只能自己寫關(guān)聯(lián)查詢語句???public function user (){ return $this-hasOne('user','id','user_id')->withTrashed();
}
- 1 回答
- 0 關(guān)注
- 1289 瀏覽
添加回答
舉報
0/150
提交
取消