Reputation: 501
Why do i get this error? I have the right relationships and in tinker, it works really well, do u guys have any idea about this?
Controller:
$emp = Empresa::find($request->empresa_id);
$mov = $emp->movimientos()->where('linea_id', intval($request->id_caso))->with('producto_nombre', 'costo_promedio');
return DataTables::of($mov)->make(true);
Thx for the help.
Upvotes: 0
Views: 122
Reputation: 4153
ambiguous
error occurs when there are multiple columns with the same name and you dont specified its table
since there are multiple table and have a column with the same name in your query you must specify the table name in your condition
$emp = Empresa::find($request->empresa_id);
$mov = $emp->movimientos()->where('movimiento.linea_id', intval($request->id_caso))->with('producto_nombre', 'costo_promedio');
return DataTables::of($mov)->make(true);
Upvotes: 1