Reputation: 28841
I have a has many through relationship like this:
class Venue {
public function orders()
{
return $this->hasManyThrough(Order::class, Offer::class);
}
}
However the Offer
model can be soft deleted: https://laravel.com/docs/5.5/eloquent#soft-deleting
This means the function, will not return any orders that have a soft deleted offer.
How can I allow the function to return orders that have soft deleted offers.
Note that I am using Laravel 5.1 (although solutions in newer versions is appreciated).
Upvotes: 1
Views: 1096
Reputation: 331
You can do it like follow :
$venue->orders()->withTrashedParents()->withTrashed();
Upvotes: 0
Reputation: 552
https://laravel.com/docs/5.1/eloquent#querying-soft-deleted-models
You can use the ->withTrashed()
method on the relationship.
Upvotes: 1