withTrashed()
can be applied to the query that retrieves the users like so:
$appointments = Appointment::with(array('user' => function($query) {
$query->withTrashed();
}))->get();
You can also apply withTrashed()
to both the appointment and their users:
$appointments = Appointment::with(array('user' => function($query) {
$query->withTrashed();
}))->withTrashed()->get();
Alternatively, you can add withTrashed()
to the association method to apply it whenever the association is loaded:
public function user() {
return $this->hasOne('User')->withTrashed();
}