Try to change the select of that query and use the id you need in that select and not the id of the joined table.
I don't follow.
Right now I've got:
$shows = Show::join('shows_titles', 'shows_titles.id', '=', 'shows.titlenu')
->with(array('productions' => function($query)
{
$query->with('production_location')
->orderBy('prodsort', 'asc');
}))
->where('title_container', 'LIKE', '%'.$search_final.'%')
->orderBy('sorttitle', 'asc')
->get();
The join is causing id to become ambiguous and, since the productions relationship uses the id in Show, it's not eager loading the results for productions.
However, I need to use the join because I need to sort by sorttitle which is in shows_titles.
Any suggestions would be greatly appreciated.
Does the show table also have and id field?
If so, rewrite your get() to the following:
get(array('show.*','shows_titles.field'))
This prevents you from getting twice the id field.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community