Is there a way to use withTrashed with relationships in Eloquent.
I need this. I have a table and a Mark model, and another User table. User has a lot of Mark and Mark belongs to User . Therefore, I defined this in Eloquent models.
Now I need to get a Mark instance that will be deleted. This is not a problem if User not a soft deletion, but if both Mark and User gently removed, I get a Trying to get property of non-object error because
$mark->user
will not return the actual user because it will be deleted.
Is there a way I can do something like
$mark->withTrashed()->user
to get the associated user even if he is deleted?
source share