I'm not 100% sure this works, as this method is meant for adding constraints to eager-loading, but you may want to try it:$appointments = Appointment::with(array('user' => function($query) { $query->withTrashed();}))->get();这应该与withTrashed()一起应用于捕获用户的查询,而不是捕获约会的查询.This should apply withTrashed() to the query that grabs the users as opposed to the query which grabs the appointments.哦,为了清楚起见,您可以在两个查询中添加withTrashed():Oh and just to clarify, you can add withTrashed() to both queries:$appointments = Appointment::with(array('user' => function($query) { $query->withTrashed();}))->withTrashed()->get();只是想到了一种更简单的方法: just thought of an easier method:将withTrashed()添加到user()关系中(仅当您希望每次调用此关系时都应用此方法时才这样做):Add withTrashed() to the user() relationship (only do this if you want this to apply EVERY time you call this relationship):public function user() { return $this->hasOne('User')->withTrashed();} 这篇关于在使用紧急加载进行查询时,如何使用withTrashed?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-11 07:26