[13.x] Qualify the default `latest()` and `oldest()` column on queries with joins
Merged
XU
18d ago+33+33+01234567890123456789-0-0-0123456789
Calling latest() or oldest() without a column on a belongsToMany, a hasManyThrough, or any query with a join returns the first page of cursor pagination, but the next page fails:
$tag->orders()->latest()->cursorPaginate(20);
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous
The default created_at column isn't qualified, so the cursor's where clause is ambiguous when the pivot or intermediate table also has timestamps.