[13.x] Fix `restore()` failing on soft delete queries with joins

Merged
XU
19d ago
+19-1

restore() fails on MySQL when the query has a join to another table that also has a deleted_at column, for example a hasManyThrough relation where both models use SoftDeletes:

$team->posts()->delete(); // works

$team->posts()->onlyTrashed()->restore();
// SQLSTATE[23000]: 1052 Column 'deleted_at' in field list is ambiguous