Closed ryanmortier closed 1 day ago
Err I managed to fix this. I tried adding the schema into the withTrashed
call and that resolves my issue. I'm not sure if this is intended or not? I'll leave open until you comment.
Solution:
->withTrashed()
->withTrashed(['maintenance.equipment.deleted_at'])
Hi @ryanmortier,
Yeah, in this case you also need to add the schema. Is the schema part of the model's $table
property?
Yes, it is. I am explicitly setting the $table
property on all my models. E.g. protected $table = 'maintenance.equipment';
The package works with the qualified deleted_at
column and that includes the schema in your case:
https://github.com/staudenmeir/belongs-to-through/blob/main/src/Relations/BelongsToThrough.php#L124
Hello,
First off, thanks so much for the package.
I'm running into an issue using this and perhaps my issue is an edge case. I'm simply trying to load a
belongsToThrough
relationship but for some reason the query is not removing the soft delete scope.This is my relationship
WorkOrder
>Equipment
>Location
A work order belongs to a location through the associated equipment.WorkOrder
Here is the SQL generated:
As you can see, the locations soft delete scope is removed but for some reason the equipment soft delete scope isn't removed. I suspect that maybe it has something to do with Equipment being both plural and singular at the same time, thus the table name is just
equipment
rather thanequipments
?Also I saw in issue #51 that you suggested using two
->withTrashed()
so that's why that is defined like that.I also tried just doing: