[13.x] Fix latest() and oldest() with a join from a subquery
Merged
XU
10d ago+19+19+01234567890123456789-2-2-0123456789
#62024 qualified the default latest() / oldest() column with the model's table when the query has joins. That breaks queries that select from a subquery, since the model's table isn't part of the query:
Post::fromSub(Post::where('published', true), 'p')
->join('users', 'users.id', '=', 'p.user_id')
->latest()
->get();
// SQLSTATE: no such column: posts.created_at
Now the column is only qualified when selecting from a plain table.