-2
I am trying to perform a query in the table "expenses" that has foreign key.
When performing the query. The "id" column of the "expenses" table is replaced by the "id" of "dismisse_categories"
I am doing the consultation as follows:
$despesas= Despesa::query()
->where('id_user', '=', "$usuario->id")
->join('despesa_categorias', 'despesas.id_des_cat', '=', 'despesa_categorias.id')
->whereYear('data_referencia', '=', "$ano")
->whereMonth('data_referencia', '=', "$mes")
->get();
My return is:
{"id":3,"id_user":1,"id_des_cat":3,"valor":42.9,"descricao":"teste","data_referencia":"2020-07-15","created_at":null,"updated_at":null,"categoria":"energia"}
Where "id" is coming from the "fare_categories" table. How can I keep the "id" of the "expenses" table when performing the query?