Christian
Christian

Reputation: 501

Laravel: SQLSTATE[23000] error with dataTables

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?

Tinker: enter image description here

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);

Error: enter image description here

Table structure: enter image description here

Thx for the help.

Upvotes: 0

Views: 122

Answers (1)

Beginner
Beginner

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

Related Questions