This PR fixes a bug that causes the BelongsToThrough relation to never return any results when the parent model is soft deleted.
Imagine the following scenario:
model A (uses SoftDeletes)
belongsTo B
belongsToThrough C
model B
belongsTo C
model C
If model A has soft deletes the relation will currently generate the following query:
select `c`.*
from `c`
left join `b` on `c`.`id` = `b`.`c_id`
left join `a` on `b`.`id` = `a`.`b_id`
where `a`.`id` = ? and `a`.`id` is not null and `a`.`deleted_at` is null
After this PR the relation will generate the following query:
select `c`.*
from `c`
left join `b` on `c`.`id` = `b`.`c_id`
left join `a` on `b`.`id` = `a`.`b_id`
where `a`.`id` = ? and `a`.`id` is not null
Note that any models that are not the parent will still have soft delete checks added to the query if they use the SoftDeletes trait.
This PR fixes a bug that causes the BelongsToThrough relation to never return any results when the parent model is soft deleted.
Imagine the following scenario:
model A (uses SoftDeletes)
model B
model C
If model A has soft deletes the relation will currently generate the following query:
After this PR the relation will generate the following query:
Note that any models that are not the parent will still have soft delete checks added to the query if they use the SoftDeletes trait.